<HTML> <HEAD> <link rel="STYLESHEET" type="text/css" href="cssClass.css"> <TITLE>ADO.NET Connection 1J5:B 10 Command 1J5:B (.0=1>;4)</TITLE> </HEAD> <BODY> <script src="coolmenus_frame.js" type="text/javascript"></script> <A NAME="VBCnnCmd"></A> <P>&nbsp;</P> <h1 align=center>ADO.NET Connection 1J5:B 10 Command 1J5:B (Visual Basic .NET)</h1> <P>&nbsp;</P> <h2 align=center>Connection 1J5:B</h2> <p> ADO.NET Connection >1J5:B =L T3T34;89= 1007K= E>;1>;BK3 ?@>3@0<< 1>;>= database engine 2-K= E>>@>=4 E89EM4 EM@M3;M=M. %M@M2 B0 TT@89= SQL Server ;vv E>;1>;B E89E 3M6 109300 1>; 40@00E <0O300@ 18G86 1>;=>. <p> <pre syntax> Provider=sqloledb;Data Source=(local);Initial Catalog=Northwind;User ID=sa;Password=; </pre> Access 2000 T3T34;89= 1007 EM@M3;ME 1>; provider-89= BM<4M3B <T@ 4>>@E 70320@B09 109=0. <p> <pre syntax> Provider=Microsoft.Jet.OleDb.4.0;Data Source=C:\Northwind.mdb </pre> <P>&nbsp;</P> <h2 align=center>Command 1J5:B</h2> <p> OleDbCommand >1J5:B =L ADO-389= command >1J5:BB>9 <0H BTABM9. -=M =L SQL <M4M34;vv4893 E0430;0= T3T34;89= MEBM9 40E8= 40E8= 068;;0E04 EM@M3;M34M=M. OleDbCommand >1J5:B =L SELECT, INSERT, UPDATE, DELETE <M4M34;vv4893 068;;CC;6 G04403 N<. <p> 8HMM<br> <img src="image/vb/SQLTest.jpg" Alt= "OleDbConnection 10 OleDbCommand >1J5:BCC4K3 EM@M3;ME"></img> <p> >>@E 68HMM=4 INSERT <M4M34;893 0H83;0= Northwind 1007K= Customers EvA=M3BM=4 <@ =M<=M. <OL> <LI>(8=MM@ SQLTester solution vvA3M.</LI> <LI>$>@<4>> txtRows, txtSQL 3MAM= 2 TextBox :>=B@>; =M<M=, 4MM@E 70320@B09 1>;3>=>. </LI> <LI>Button-4>> btnExecute 3MAM= =M@ T3T=, Click 7M34M; 4MM@ 40@00E :>4K3 18G=M vv.</LI> </OL> <pre syntax> Private Sub btnExecute_Click(ByVal sender As Object, ByVal e As System.EventArgs) _ Handles btnExecute.Click Dim oCmd As OleDb.OleDbCommand Dim strConn As String Try '%>;1>;BK= BM<4M3B <@ strConn = "Provider=sqloledb;" strConn &= "Data Source=(local);" strConn &= "Initial Catalog=Northwind;" strConn &= "User ID=sa;" strConn &= "Password=;" ' Command 1J5:B vvA3ME oCmd = New OleDb.OleDbCommand() ' Command 1J5:B>4 EM@M3;M34ME %>;1>;B E89E oCmd.Connection = New OleDb.OleDbConnection(strConn) ' %>;1>;BK3 =MME oCmd.Connection.Open() ' SQL-893 TextBox->>A 020= Command 1J5:B>4 @CC E89E oCmd.CommandText = txtSQL.Text ' SQL-893 068;;CC;0=, =89B TT@G;T34AT= 18G;M389= B>>3 TextBox-4 >=>>E txtRows.Text = oCmd.ExecuteNonQuery().ToString() MessageBox.Show("SQL <M4M34M; 0<68;BB09 185;M;MM ", "btnExecute_Click()") ' %>;1>;BK3 E00E oCmd.Connection.Close() Catch oExcept As Exception txtRows.Text = 0.ToString() MessageBox.Show("SQL 068;;0E O2F04 0;400 30@;00: " & oExcept.Message, _ "btnExecute_Click()") End Try End Sub </pre> Command >1J5:BK= ExecuteNonQuery method-K3 068;;CC;A=00@ T3T34;89= 100704 CommandText 40E SQL <M4M34M; <00=L EM@M368=M. TT@TT@ EM;1M; T3T34;89= 100704 <T@ =M<ME v9;4;893 E89=M. <p> "0 F5 B>2G 40@0= ?@>3@0<<00 068;;CC;=0. INSERT <M4M34M; 109300 text box-4 7T2 INSERT, UPDATE, DELETE <M4M34;vv4893 18G86 Execute SQL B>2GK3 40@0= 068;;03003 =L H0;300@09. <P>&nbsp;</P> <P align="center"><a href="ADONET.html">ADO.NET-= 1vBMF, EM@M3;ME</a> | <a href="#VBCnnCmd"> 4MMHMM 1CF0E</a> | <a href="VBDataBinding.html">3T34T; 1ME;ME</a> <br> <a href="Main.html">=vv@ ECC40A</a></P <P>&nbsp;</P> </BODY> </HTML>