|
With this type of String Concatination you will have problems.
Always put your Connection String in your WebConfig
like this
How to Store and Retrieve a ConnectionString from a Web.Config or App.Settings File[^]
Your First part of the Connection string is not Correct.
change your connection string from this
"Data Source = https://sbbMedical.com\localhost; Initial Catalog = sbbmhcom_medihealth;Integrated Security=False;User Id= '" & UserIdTextBox.Text & "'; Password= '" &PasswordTextBox.Text &"'"
to
"Data Source =VUYISWA\SQLEXPRESS; Database= sbbmhcom_medihealth;Integrated Security=False;User Id= '" & UserIdTextBox.Text & "'; Password= '" &PasswordTextBox.Text &"'"
i have change the HTTP to the name of the SQLEXPRESS i have locally on my machine. To know the name of your sql name ,just open management studio and try to connect , use the name displayed on the server name not the http.
Tell me after that if the Error changes
Vuyiswa Maseko,
Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.somee.com
http://www.vuyiswamaseko.tiyaneProperties.co.za
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
Thanks Vuyiswa!
I have tried ur suggestions as follows:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key ="MyCon" value ="User id= UserIdTextBox.Text;
Password=PasswordTextBox.Text;Data Source =mark.internet-webhosting.com\SQLEXPRESS;Trusted_Connection=Yes; Database=sbbmhcom_TESTDB"></add>
</appSettings>
</configuration>
And
Dim str As String = System.Configuration.ConfigurationManager.AppSettings("MyCon")
'open connection
myConnection.ConnectionString = (str)
myConnection.Open()
But with the following error:
login failed for user" . The user is not associated with a trusted SQL server connection.
Do I need to do any further configuration?
And for ur info. my firewall is disabled, I no its not save but this project is my priority at the moment.
Any more advice/suggestions/corrections?
Am just a newbie!!
Thanks for ur time!
|
|
|
|
|
Good Morning ChiSmile
in your Server Properties go to Security and make sure that both Windows Authontication and SQL Server Authontication is checked.i think now its only Windows Authontication.
And that will solve your Problem
Thanks
Vuyiswa Maseko,
Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.somee.com
http://www.vuyiswamaseko.tiyaneProperties.co.za
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
Thank Vuyiswa, u are the best! it worked just fine!
But do u know how i can use windows emulator to access the database.
The applications I've written is in VB.net using visual studio professional 2008, one is mobile and the other is desktop.
The application (mobile) should be able to collect data from field work and store it dirctly on the server database while the desktop application should act as the admin to create users and do other admin stuffs.
So any help? I hope this is the right forum for this!!
Anyway, Thanks in advance
|
|
|
|
|
Good Morning ChiSmile
Am glad i helped. I have never done any mobile Development. Chris or Colin will give you the answer to that one. they might know.
Thanks
Vuyiswa Maseko,
Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.somee.com
http://www.vuyiswamaseko.tiyaneProperties.co.za
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
A Real Work at Home Opportunity as an Independent Advertising Executive. We offer home workers the opportunity to earn extra money from the comfort of their own home. Visit Us at http://www.clicknearn.net/idevaffiliate/ idevaffiliate.php?id=3016_9
|
|
|
|
|
Voted for removal
"please help in this regard. give the visual basic code for this as soon possible."
|
|
|
|
|
I have to copy data using sql bulk copy control. it's give error for Computed columns.
pls help me to solve out.
-jay
|
|
|
|
|
We cant know until you give us more information about your problem
Vuyiswa Maseko,
Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.somee.com
http://www.vuyiswamaseko.tiyaneProperties.co.za
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
Hi Guys,
I have slq server 2008 installed in my pc, I enabled Intellisense too, but I cant see that anytime I type a query .
Please help
Thanks
Ramm
|
|
|
|
|
Which OS are you using?
Manas Bhardwaj
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
Hi,
I am using Windows XP version 2002, service pack 3.
Thanks
Ramm
|
|
|
|
|
Hi ,
In a SQL View, I have 5 boolean variables and one int variable.
out of 5 boolean variables only one variable will be true for a single data row,
Task Type boolVerySmall Datestart TagName
----------------------------------------------------------------------------------
Architecture Setup -- Doc Code True 1900-01-01 00:00:00.000 Design_09
idProject boolsmall boolMedium boolLarge boolVeryLarge intHours
----------------------------------------------------------------------------
4 False False False False 0
The above data is for one row... in this row, when I download the data from database to excel sheet, I have to display only the value which is true (boolVerySmall ,boolsmall, boolMedium,boolLarge, boolVeryLarge, intHours) should be displayed in a s ingle column,
I have written a Stored procedure for this. I am finding it difficult to get a particular row which has TRUE of intHours>0.
I am adding the sql query below. Please help me
> SELECT dbo.tblResourceTaskList.txtTask, dbo.tblIndividualRelativeData.txtProductType, dbo.tblResourceTaskList.boolVerySmall,
dbo.tblResourceTaskList.dtActualCompletionDate, dbo.tblEffortCodes.txtTagName, dbo.tblResourceTaskList.txtTaskNotes, dbo.tblResourceTaskList.idSubProject, dbo.tblResourceTaskList.idLaunch, dbo.tblResourceTaskList.idResource, dbo.tblResourceTaskList.boolSmall, dbo.tblResourceTaskList.boolMedium, dbo.tblResourceTaskList.boolLarge, dbo.tblResourceTaskList.boolVeryLarge,
dbo.tblResourceTaskList.intDirectHours
FROM dbo.tblResourceTaskList INNER JOIN dbo.tblProjectUsers ON dbo.tblResourceTaskList.idSubProject = dbo.tblProjectUsers.idSubProject AND
dbo.tblResourceTaskList.idResource = dbo.tblProjectUsers.idUser INNER JOIN
dbo.tblLaunchInfo ON dbo.tblResourceTaskList.idLaunch = dbo.tblLaunchInfo.idLaunch INNER JOIN dbo.tblIndividualRelativeData ON dbo.tblResourceTaskList.idIndividualRelativeEffort = dbo.tblIndividualRelativeData.idIndividualRelativeEffort LEFT OUTER JOINdbo.tblEffortCodes ON dbo.tblResourceTaskList.idEffortCode = dbo.tblEffortCodes.idEffortCode
My stored procedure is
SELECT txtTask, txtProductType, **boolVerySmall**, txtTagName, txtTaskNotes,
dtActualCompletionDate
FROM tblResourceTaskList_View
WHERE (idSubProject = @idSubProjectIndex )
as the first row from db has TRUE for boolVerySmall, then SP should return this value and if its other than that it should give that value.
Instead of filling *True* in excel sheet, I , have to assign VS for boolVerySmall, S - Small, M - Medium, L - Large VL- VeryLarge in the excelsheet.
So please help me how to work on this.
1. Assigning shortnames (like VS... for the bool var's).
2. Returning only one value (boolverysmall or ... ) and assigning VS to that and fill it in excel.
3. if all the bools are false, then intHours should be assinged...
Kindly help me.
Thanks
Ramm
|
|
|
|
|
Firstly your data structure *sucks*, you should redesign your table to have 1 column for size and 5 possible values. If possible do this NOW, if you leave it you will continually be plagued by this issue.
In the select part of you query use a nested CASE statement,
Case When size1 is null then 'S' else
Case when size2 is null then 's1' else
Case when size3 is null then 's2'
end end end as Size
You get the picture. Fix you structure if at all possible, if you own it then suck it up and make the changes, pay the cost for lousy design NOW, it only gets more expensive the longer you leave it.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Thanks a lot for your reply.
I sorted out some other way to display this.
Thank you,
Aditya
|
|
|
|
|
Well,post here that solution because it can be helpfull for someone else.
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
|
|
|
|
|
Hi All.
I have a stored procedure which returns a set of records. I have an optional parameter in there, so the idea is the proc will return all records if the parameter is null, otherwise filter the results.
Code:
CREATE PROC sp_MyProc (@ItemID AS INT)
AS
BEGIN
SELECT *
FROM myTable
WHERE ItemID LIKE CASE WHERE @ItemID IS NULL THEN '%' ELSE '%' + @ItemID END
END
Is there a more effient way of doing this without repeating the query with an IF statement? (My Actual query is quite lengthy, so repeating the code will be messy)
Thanks in advance
oooo, the Jedi's will feel this one....
|
|
|
|
|
CREATE PROC sp_MyProc (@ItemID AS INT)
AS
BEGIN
SELECT *
FROM myTable
WHERE ItemID=isNull(@ItemID,ItemID)
END
Check out IsNull[^].
It checks whether the parameter is null and in case it finds it to be null, returns back the column queried which indicates an (1=1) condition.
hope the explanation is clear enough.
When you fail to plan, you are planning to fail.
|
|
|
|
|
Thats great. Thank you.
Just one question though: If this were to be run against a large table, would the fact that a where clause is included impact the performance? or would the 1=1 condition make it run just as fast as if there were no where clause?
oooo, the Jedi's will feel this one....
|
|
|
|
|
I like the ISNULL example above, but I have a feeling it will affect performance - I have reservation as to whether SQL will correctly use indexes when resolving the function call.
Ive always used this method, which I know works:
SELECT *
FROM myTable
WHERE @ItemID IS NULL OR ItemId = @ItemId
Also, depending on which version of SQL Server you're using, prefixing your stored proc with sp_ affects performance in that it looks in the master db first. I think you'd have to be using a very old version for this to be true, but its good practice not to use an sp_ prefix - if you really like prefixes use usp_ to distinguish from in-build sp's.
|
|
|
|
|
Thats just what I'm after. Thanks.
oooo, the Jedi's will feel this one....
|
|
|
|
|
If it's a simple query then it's OK to do this:
IF @ItemID IS NULL
BEGIN
SELECT * FROM myTable;
END
ELSE
BEGIN
DECLARE @like NVARCHAR(6)
SET @like = '%' + CAST(@ItemID AS NVARCHAR(5))
SELECT * FROM MyTable WHERE ItemID LIKE %like;
END
Or similiar depending on your needs.
Jeremy Likness
http://csharperimage.jeremylikness.com/
|
|
|
|
|
Ive also used this method, but i think the OP suggested that the query was long and complex - and therefore duplicating the code inside IF logic was going to get tough.
Good answer though. The OP now has all 3 possible methods!
|
|
|
|
|
Hi. I've a table Project(ProjectId, ParentProjectId, ProjectName)
the sample data are --------------------------
1,0, X
2,1,Y
3,2,Z
4,3,W
now for a given project id i want to get projectid, projectname for a given projectid.
e.g. i want 1,X for projectid = 4
i want to SQL query for this. plz help me.
|
|
|
|
|
So what have you tried? Anyone who has read more than 1 chapter of a book on SQL or has spent more than 10 minutes learning what to do can answer this. It is so basic that I suspect you tobe a troll.
Never underestimate the power of human stupidity
RAH
|
|
|
|