Dim conn As new ADODB.Connection
解决方案 »
- SQL数据库语句哪里查?
- 只有在配置文件或 Page 指令中将 enableSessionState 设置为 true 时,才能使用会话状态。还请确保在应用程序配置的 <configuration>\<system.web>\<httpModules> 节中包括 System.We
- asp.net相对asp的优势是什么,并说明原因
- 滚动repeater控件中的数据源.急!!!
- 打开新窗口的怪问题,请指点,在线等,谢谢。
- showModalDialog()无法关闭
- 关于checkbox未选中的问题!!!急啊!!!!
- [xml问题]:如何自动生成xml文件?
- SqlServer数据库的连接问题!
- 求救?怎样将库中表的字段动态地加入到DataGrid中?
- 如何删除listBox中的相同项;具体是这样在listbox中可能有好多项是相同的,但只能保留一个,如何实现?在线等;
- 请问我点取datagrid里的一条记录,然后弹出一个窗口,在窗口里显示有关这条记录的内容,哪位大侠能给个正确答案!谢谢!!
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.NullReferenceException: 未将对象引用设置到对象的实例。源错误:
行 34: Dim conn As New ADODB.Connection()
行 35: Dim com As New ADODB.Command()
行 36: conn.Open("driver={SQL Server};server=shanle;uid=sa;pwd=sa;database=OaExpand")
行 37: conn.Close()
{
OleDbDataAdapter custDA = new OleDbDataAdapter();
DataTable dtTerritories = new DataTable("Territories");
ADODB.Connection adoConn = new ADODB.Connection();
ADODB.Recordset adoRS = new ADODB.Recordset();
adoConn.Open("Provider=SQLOLEDB;Data Source=localhost;Initial Catalog=Northwind;User Id=;Password=;", "", "", -1);
adoRS.Open("SELECT TerritoryID, TerritoryDescription FROM Territories Order By TerritoryDescription", adoConn, ADODB.CursorTypeEnum.adOpenForwardOnly, ADODB.LockTypeEnum.adLockReadOnly, 1);
custDA.Fill(dtTerritories, adoRS);
adoRS.Close();
adoConn.Close();
adoRS = null;
adoConn = null;
DataGrid1.DataSource = dtTerritories;
DataGrid1.DataBind();
DropDownList1.DataSource = dtTerritories;
DropDownList1.DataValueField = "TerritoryID";
DropDownList1.DataTextField = "TerritoryDescription";
DropDownList1.DataBind();
}
Dim objConn As New SqlClient.SqlConnection(strConn)
Dim strSql As String = "SELECT user_id, user_name, user_pwd, dept_id, user_order FROM dbo.[user]"
Dim objCmd As New SqlClient.SqlCommand(strSql, objConn)
dgNameList.DataSource = objCmd.ExecuteReader()
dgNameList.DataBind()
objConn.Close()我这样写还是错误,不明白、了,说的是Provider=SQLOLEDB.1;Password=sa;Persist Security Info=True;User ID=sa;Initial Catalog=jnjl;Data Source=shanle"这个有错误
“/jnjl”应用程序中的服务器错误。
--------------------------------------------------------------------------------连接字符串 provider 中未知的连接选项。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.ArgumentException: 连接字符串 provider 中未知的连接选项。源错误:
行 42: Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
行 43: Dim strConn As String = "Provider=SQLOLEDB.1;Password=sa;Persist Security Info=True;User ID=sa;Initial Catalog=jnjl;Data Source=shanle"
行 44: Dim objConn As New SqlClient.SqlConnection(strConn)
行 45: Dim strSql As String = "SELECT user_id, user_name, user_pwd, dept_id, user_order FROM dbo.[user]"
行 46: Dim objCmd As New SqlClient.SqlCommand(strSql, objConn)
源文件: C:\Inetpub\wwwroot\jnjl\login.aspx.vb 行: 44 堆栈跟踪:
Dim conn As New ADODB.Connection()
Dim com As New ADODB.Command()
'Dim sql As String
conn.Open("Provider=SQLOLEDB;driver={SQL Server};server=shanle;uid=sa;pwd=sa;database=jnjl")
com.ActiveConnection = conn
'sql = "SELECT user_id, user_name, user_pwd, dept_id, user_order FROM dbo.[user]"
com.CommandText = "SELECT user_id, user_name, user_pwd, dept_id, user_order FROM dbo.[user]"
com.CommandType = 1
rs = com.Execute()
While Not rs.EOF
Dim aa
aa = rs("user_name")
ListBox1.Items.Add("11")
'ListBox1.Items.Add(rs("user_name"))
rs.MoveNext()
End While
'DataList1.DataSource = rs
'DataList1.DataBind()
conn.Close()就差一点点了,这样是正常的,但是加上这个'ListBox1.Items.Add(rs("user_name"))
就不能了,好像数据不对,我不明白,谁能给详细解释一下我的问题,分不够在开帖子给