-
Dataset fill
Hi i am trying to connect to a database using an sql adapter, when i fill the dataset i get an error in the output window it says
"Unhandled Exception: System.Data.SqlClient.SqlException: Cannot open database requested in login 'testbooking'. Login fails."
But the server does exsit and so does the database
i can connect using an oledb adapter but i really dont want to have to
any help would be great
-
here is what connection should look like:
SQL Autentication:
data source=YOURSERVERNAME;persist security info=False;initial catalog=YOURDATABASENAME;user id=sa;password=YOURPASS;
Windows Autentication:
data source=YOURSERVERNAME;persist security info=False;initial catalog=YOURDATABASENAME;integrated security=SSPI;
-
And is it a SQL Server? That's the only way the SQL Adapter is going to work. The fact that you can connect using the OLEDB Adapter leads me to suspect that it isn't a SQL Server, but something else./
Tg
-
No it is SQL server it just giives me an error with the sql adapter method. I will try you way and keep you posted thanks
-
The connection you posted is the same as mine but it throughs the error message back???
-
can you post your connection string
-
Point of order your honor! It's a bad idea to use the sa user for connecting to the database, case DBA vs SA-User-With-No-Password of 1997. I move that the user be stricken from the access list.
If you do post your connectionstring, post it EXACTLY as it is, but use **** for the password.... we don't need to see that.
Tg
-
connection with the database
if your dataadapter contains no tables then dataset cannot be populated and it will show an error when you write the command
sqlclient.sqldataadapter.fill(dataset(),<tablename >)
so check if your dataadapter is not linked with any table of your database
-
Hi thanks for your help with this, i have moved on and am now using the oledb adapter but have come across anothe problem, i generate this through the wizard and when it has finsihed it tells me it can not create the update or delete commands.
My project as it stands is this:
I have an excel sheet with two coloums one called URN and one invoiecno, i import the data into a dataset > ds1, i then have a tables called jobs in sql server i create a dataset> ds2 with coulms urn and invoice number. i wish to update the sql server table coloum invoice number to the invoice number in the excel sheet where the urn are the same in ds1 & ds2
any help would be great
-
The erro message i get is:
An unhandled exception of type 'System.InvalidOperationException' occurred in system.data.dll
Additional information: Update requires a valid UpdateCommand when passed DataRow collection with modified rows.
my code is
PrivateSub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
DataSet11.Clear()
OleDbDataAdapter1.Fill(DataSet11)
EndSub
PrivateSub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
OleDbDataAdapter1.Update(DataSet11)
MessageBox.Show("Datbase Updated")
EndSub
-
u have used the following set of code:
PrivateSub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
OleDbDataAdapter1.Update(DataSet11)
MessageBox.Show("Datbase Updated")
EndSub
this is the right one:-
whenever u are updating dataadapter in this manner then u must first instantiate the commandbuilder object.
dim objcommandbuilder as new sqlclient.sqlcommandbuilder(objdataadapter)
oledbdatadapter1.update(dataset11,<tablename>)
u have to provide the tablename option.
-
ok manged to sort previous post out have one more snag?
on the line
objdataview.Table(0).ow(inum).item("URN") = "TEST"
it says it can not be indexed because it has no default value
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
Bookmarks