千
千中元
Unregistered / Unconfirmed
GUEST, unregistred user!
连接都错了。。。
代码如下:
Label6和Label7显示的错误信息:
错误Microsoft OLE DB Provider for SQL Server
Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;User ID=sa;Initial Catalog=psyTest;Data Source=QIANQIAN;Use Procedure for Prepare=1;Auto Translate=True;Packet Size=4096;Workstation ID=QIANQIAN;
Use Encryption for Data=False;Tag with column collation when possible=False
问题是这个连接,我用Delphi的AdoConnection试过是可以的。
代码如下:
代码:
string strConnect = ConfigurationSettings.AppSettings["DsnUserList"];
string userName = tbUserName.Text.Trim();
string Sex = ddlSex.SelectedItem.Text.Trim();
int Age =Int32.Parse(this.tbAge.Text.Trim());
string Email = tbEmail.Text.Trim();
string strSQL = "SELECT TOP 1 * FROM USER";
try
{
// create a new Connection object
OleDbConnection objConnect = new OleDbConnection(strConnect);
// open the connection to the database
// objConnect.Open();
OleDbCommand selectCMD = new OleDbCommand(strSQL, objConnect);
selectCMD.CommandTimeout = 30;
OleDbDataAdapter custDA = new OleDbDataAdapter();
custDA.SelectCommand = selectCMD;
DataSet custDS = new DataSet();
custDA.Fill(custDS,"USER");
DataRow myNewRow;
myNewRow = custDS.Tables["USER"].NewRow();
myNewRow["UserName"] = userName;
myNewRow["UserSex"] = Sex;
myNewRow["UserAge"] = Age;
myNewRow["UserEmail"] = Email;
custDS.Tables["USER"].Rows.Add(myNewRow);
custDS.AcceptChanges();
custDA.Update(custDS);
}
catch (Exception objError)
{
Label6.Text="错误"+objError.Source;
Label7.Text=strConnect;
return; // and stop execution
}
错误Microsoft OLE DB Provider for SQL Server
Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;User ID=sa;Initial Catalog=psyTest;Data Source=QIANQIAN;Use Procedure for Prepare=1;Auto Translate=True;Packet Size=4096;Workstation ID=QIANQIAN;
Use Encryption for Data=False;Tag with column collation when possible=False
问题是这个连接,我用Delphi的AdoConnection试过是可以的。