Click here to Skip to main content
16,020,840 members

Comments by anand4886 (Top 13 by date)

anand4886 16-Apr-12 14:55pm View    
i want to add data in sql server table from vb.net application,my code block is

Imports System.Data.SqlClient
Imports System.Data.SqlClient.SqlConnection

Public Class Form1
Dim cn As SqlConnection

Dim ConStr As String
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ConStr = "Data Source=ANAND-PC\SQLEXPRESS;Initial Catalog=anand;User ID=;Password="
cn = New SqlConnection(ConStr)

End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim cmd As New SqlClient.SqlCommand
Dim query As String
query = "Insert Into anand1 (roll) values (" & TextBox1.Text & ");"

cmd.CommandText = query
cmd.CommandType = CommandType.Text
cmd.Connection = cn

cn.Open()

cmd.ExecuteNonQuery()

cn.Close()

End Sub
End Class


it is showing some error in cn.open

pls help its very urgent
anand4886 16-Apr-12 5:52am View    
pls tell me how can i open sql management studio editor
anand4886 15-Apr-12 11:05am View    
i have installed the sql server but unable to open the sql management studio
anand4886 4-Apr-12 14:37pm View    
Dim cmd As New MySqlCommand

cmd .CommandText = "Insert Into try (Name) values ("Simon")"
cmd.CommandType = CommandType.Text
cmd.Connection = cn

cn.Open()

cmd.ExecuteNonQuery()

cn.Close()
but in cmd.commondtext line .net is showing an error that "end of statement expected",pls correct my code
anand4886 31-Mar-12 7:25am View    
when i select add refrence than a dialog box appears and it contains .net,com,project,browse,recent,which opttion should i search or select