توجه ! این یک نسخه آرشیو شده میباشد و در این حالت شما عکسی را مشاهده نمیکنید برای مشاهده کامل متن و عکسها بر روی لینک مقابل کلیک کنید : اتصال به پايگاه داده در vb.net
Gladiator
12-07-2009, 03:17 PM
اتصال به پايگاه داده در vb.net
عباسعلي شياري
farzadho
12-07-2009, 04:48 PM
این مثال هم میتونه کمک کنه...
البته با شی dataset کار شده..
Gladiator
12-25-2009, 07:41 AM
Dim conn As New SqlConnection("Data Source=.\SQLEXPRESS;" + "Initial Catalog=greypanther;" + "Integrated Security=True;") 'Using integrated security to connect, since SQL connection is playing up.
Try
Dim cmd As New SqlCommand 'SqlCommand declared, allows us to send commands to server.
Dim params As SqlParameterCollection = cmd.Parameters
cmd.CommandTimeout = 5
cmd.Connection = conn 'Hooks into the declared SqlConnection.
cmd.CommandType = CommandType.Text 'Tells SqlCommand we're going to be using simple text based SQL queries.
conn.Open() 'Opens the SQL connection.
If conn.State = ConnectionState.Open Then
cmd.CommandText = "SET IDENTITY_INSERT Customers ON;INSERT INTO Customers(address,name,family) VALUES ('" + ComboBox1.Text + "', '" + TextBox1.Text + "', '" + TextBox2.Text + "', '" + TextBox4.Text + "', '" + _
TextBox5.Text + "', '" + TextBox6.Text + "', '" + TextBox7.Text + "', '" + TextBox11.Text + "', '" + TextBox12.Text + "', '" + TextBox11.Text + "', '" + _
TextBox10.Text + "', '" + TextBox9.Text + "', '" + RadioButton1.Checked.ToString + "', '" + NumericUpDown1.Value.ToString + "', '" + TextBox8.Text + "', '" + _
TextBox16.Text + "', '" + TextBox13.Text + "', '" + TextBox19.Text + "', '" + (TextBox18.Text + TextBox17.Text) + "', '" + (TextBox15.Text + TextBox14.Text) + "', '" + ComboBox2.Text + "')"
cmd.ExecuteNonQuery()
End If
Catch ex As Exception
MessageBox.Show(ex.Message, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Error) 'Report exception.
End Try
conn.Close() 'Closes SQL connection.
[Only registered and activated users can see links]
vBulletin® v3.8.4, Copyright ©2000-2012, Jelsoft Enterprises Ltd.