Click here to Skip to main content
15,913,722 members
Home / Discussions / Database
   

Database

 
GeneralRe: database Pin
David Salter5-Aug-02 11:33
David Salter5-Aug-02 11:33 
GeneralBulk loading in .Net Pin
Anonymous27-Jul-02 8:57
Anonymous27-Jul-02 8:57 
GeneralRe: Bulk loading in .Net Pin
Andres Manggini27-Jul-02 12:16
Andres Manggini27-Jul-02 12:16 
GeneralRe: Bulk loading in .Net Pin
Anonymous27-Jul-02 18:41
Anonymous27-Jul-02 18:41 
GeneralRe: Bulk loading in .Net Pin
stephen woolhead29-Jul-02 5:38
stephen woolhead29-Jul-02 5:38 
GeneralSequential Number Pin
Waleed Eissa27-Jul-02 6:37
Waleed Eissa27-Jul-02 6:37 
GeneralSQL Server, OLE DB problem Pin
Alex Deem26-Jul-02 2:23
Alex Deem26-Jul-02 2:23 
GeneralXML Web Service error on Update() Pin
laphijia25-Jul-02 23:45
laphijia25-Jul-02 23:45 
This is the code of an XML Web Service that Query an SQL Server.
It takes two strings and returns a DataSet.
It's a simple excercise, It query the database, populate a DataSet, modify a Field and Update the changes.

[WebMethod]
public DataSet GetUserData(string szUsername, string szNewLocalName)
{
string szSqlCommand = "SELECT * FROM Locals WHERE Username = '" + szUsername + "'";
SqlConnection myConnection = new SqlConnection(" User ID=sa;Password=password;Initial Catalog=laphijia;Data Source=(local)");
SqlDataAdapter mySqlDataAdapter = new SqlDataAdapter(szSqlCommand, myConnection);
DataSet myDataSet = new DataSet();


mySqlDataAdapter.UpdateCommand = new SqlCommand("UPDATE Locals SET LocalName = @LocalName" +
"WHERE Username = @Username", myConnection);

mySqlDataAdapter.UpdateCommand.Parameters.Add("@LocalName", SqlDbType.NVarChar, 25, "LocalName");
SqlParameter workParam = mySqlDataAdapter.UpdateCommand.Parameters.Add("@Username", SqlDbType.NVarChar, 25);
workParam.SourceColumn = "Username";
workParam.SourceVersion = DataRowVersion.Original;


mySqlDataAdapter.Fill(myDataSet, "Locals");


myDataSet.Tables["Locals"].Rows[0]["LocalName"]= szNewLocalName;
mySqlDataAdapter.Update(myDataSet, "Locals");


return myDataSet;
}



I made this with help from the MSDN NET Framework Developer's Guide article Updating the Database with a DataAdapter and the DataSet.

When I try to access the Web Service and Invokes it, I get a 505 Internal Server Error.
I tried to remove the line:
mySqlDataAdapter.Update(myDataSet, "Locals");

and it works (it returns the DataSet as XML data, but obviously don't update the DataBase.

What's wrong with my code?
I also tried with the SQL Command Builder, but it's just the same.
Thank You.

"Nelle cose del mondo non e' il sapere ma il volere che puo'."
GeneralError Creating SQL DB in .NET Pin
bingo199525-Jul-02 2:25
bingo199525-Jul-02 2:25 
GeneralRe: Error Creating SQL DB in .NET Pin
Alexandru Savescu25-Jul-02 5:34
Alexandru Savescu25-Jul-02 5:34 
GeneralRe: Error Creating SQL DB in .NET Pin
Nick Parker25-Jul-02 7:55
protectorNick Parker25-Jul-02 7:55 
Questionhow to set a database only permit seraral IP can connet with odbc or oledb? Pin
realfly24-Jul-02 17:46
realfly24-Jul-02 17:46 
AnswerRe: how to set a database only permit seraral IP can connet with odbc or oledb? Pin
Nick Parker25-Jul-02 8:04
protectorNick Parker25-Jul-02 8:04 
GeneralRe: how to set a database only permit seraral IP can connet with odbc or oledb? Pin
realfly25-Jul-02 15:28
realfly25-Jul-02 15:28 
GeneralRe: how to set a database only permit seraral IP can connet with odbc or oledb? Pin
Nick Parker28-Jul-02 11:19
protectorNick Parker28-Jul-02 11:19 
GeneralADO asynchronous queries and sorting Pin
Byteman24-Jul-02 8:01
Byteman24-Jul-02 8:01 
GeneralRe: ADO asynchronous queries and sorting Pin
SimonS24-Jul-02 22:18
SimonS24-Jul-02 22:18 
GeneralADO.Net updating a BLOB Pin
MrGlover23-Jul-02 19:01
MrGlover23-Jul-02 19:01 
GeneralRe: ADO.Net updating a BLOB Pin
Richard Deeming25-Jul-02 1:38
mveRichard Deeming25-Jul-02 1:38 
Generaloledb and table with no key Pin
AlexEg23-Jul-02 2:22
AlexEg23-Jul-02 2:22 
GeneralRe: oledb and table with no key Pin
Alex Deem26-Jul-02 2:25
Alex Deem26-Jul-02 2:25 
GeneralCreating Login Pin
Mazdak22-Jul-02 19:14
Mazdak22-Jul-02 19:14 
GeneralRe: Creating Login Pin
Richard Deeming22-Jul-02 23:39
mveRichard Deeming22-Jul-02 23:39 
GeneralRe: Creating Login Pin
Mazdak25-Jul-02 7:14
Mazdak25-Jul-02 7:14 
GeneralDatagrid columns Pin
Ryan284522-Jul-02 5:37
Ryan284522-Jul-02 5:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.