Working in ASP.NET

xiaoxiao2021-03-05  31

Add a lot of new features in ADO.NET

VB.NET/

Dim strSql As String strSql = "SELECT * FROM BOMNOTICE WHERE (RTIME between @BEGTIME and @ENDTIME)" Dim da As New (strSql, m_strConn) Dim ds As New DataSet da.SelectCommand.CommandType = CommandType.Text Dim Par1 As New SqlParameter ( "@BEGTIME", SqlDbType.DateTime) Dim Par2 As New SqlParameter ( "@ ENDTIME", SqlDbType.DateTime) Par1.Direction = ParameterDirection.Input Par2.Direction = ParameterDirection.Input da.SelectCommand.Parameters.Add (Par1) da .SelectCommand.Parameters.add (PAR2) PAR2.Value = system.datetime.now.adddays (1) Par1.Value = system.datetime.now.adddays (-6) da.fill (DS) DataGrid1.dataSource = DS. Tables (0) .defaultView DataGrid1.database ()

C #

string strconn; string strSql; strconn = "data source = MG1116B // AAA; initial catalog = ERPTEST; user = sa; password = zaq12wsx; connection timeout = 30"; strSql = "SELECT * FROM BOMHISTRY WHERE TYPE = @ TYPE"; SqlDataAdapter da = new SqlDataAdapter (strSql, strconn); SqlParameter Par = new SqlParameter ( "@ TYPE", SqlDbType.NVarChar, 10); Par.Value = txtMessage.Text; da.SelectCommand.Parameters.Add (Par); DataSet ds = New DataSet (); DA.FILL (DS, "TENG"); DataGrid1.datasource = DS.TABLES ["teng"]. DefaultView; DataGrid1.dataBind ();

转载请注明原文地址:https://www.9cbs.com/read-39207.html

New Post(0)