Dim DataTable As DataTable
Dim currRec, totalRec As Integer
Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs ) Handles btnSave.Click
Dim objConnection As SqlConnection = New SqlConnection("user id=sa;Password=jimwest;data source=SUPRO;persist security info=False;initial catalog=pubs")
Dim objCommand As New SqlCommand
Dim ds As New DataSet
objCommand.Connection = objConnection
objCommand.CommandText = "select au_id,au_lname,au_fname from authors"
Dim dataAdaptor As New SqlDataAdapter
dataAdaptor.SelectCommand = objCommand
dataAdaptor.SelectCommand.Connection = objConnection
dataAdaptor.Fill(ds, "auth")
DataTable = ds.Tables("prog")
currRec = 0
totalRec = DataTable.Rows.Count
txtId.Text = DataTable.Rows(currRec)("au_id").ToString()
txtLast.Text = DataTable.Rows(currRec)("au_lname").ToString()
txtFirst.Text = DataTable.Rows(currRec)("au_fname").ToString()
End SubDim DataTable As DataTable
Dim currRec, totalRec As Integer
Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs ) Handles btnSave.Click
Dim objConnection As SqlConnection = New SqlConnection("user id=sa;Password=jimwest;data source=SUPRO;persist security info=False;initial catalog=pubs")
Dim objCommand As New SqlCommand
Dim ds As New DataSet
objCommand.Connection = objConnection
objCommand.CommandText = "select au_id,au_lname,au_fname from authors"
Dim dataAdaptor As New SqlDataAdapter
dataAdaptor.SelectCommand = objCommand
dataAdaptor.SelectCommand.Connection = objConnection
dataAdaptor.Fill(ds, "auth")
DataTable = ds.Tables("auth")
currRec = 0
totalRec = DataTable.Rows.Count
txtId.Text = DataTable.Rows(currRec)("au_id").ToString()
txtLast.Text = DataTable.Rows(currRec)("au_lname").ToString()
txtFirst.Text = DataTable.Rows(currRec)("au_fname").ToString()
End Sub
I have already checked with the SQl server logins and right..Everything is okay..A similar code works on my friends machine..what could be the reason
Dim currRec, totalRec As Integer
Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs ) Handles btnSave.Click
Dim objConnection As SqlConnection = New SqlConnection("user id=sa;Password=jimwest;data source=SUPRO;persist security info=False;initial catalog=pubs")
Dim objCommand As New SqlCommand
Dim ds As New DataSet
objCommand.Connection = objConnection
objCommand.CommandText = "select au_id,au_lname,au_fname from authors"
Dim dataAdaptor As New SqlDataAdapter
dataAdaptor.SelectCommand = objCommand
dataAdaptor.SelectCommand.Connection = objConnection
dataAdaptor.Fill(ds, "auth")
DataTable = ds.Tables("prog")
currRec = 0
totalRec = DataTable.Rows.Count
txtId.Text = DataTable.Rows(currRec)("au_id").ToString()
txtLast.Text = DataTable.Rows(currRec)("au_lname").ToString()
txtFirst.Text = DataTable.Rows(currRec)("au_fname").ToString()
End SubDim DataTable As DataTable
Dim currRec, totalRec As Integer
Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs ) Handles btnSave.Click
Dim objConnection As SqlConnection = New SqlConnection("user id=sa;Password=jimwest;data source=SUPRO;persist security info=False;initial catalog=pubs")
Dim objCommand As New SqlCommand
Dim ds As New DataSet
objCommand.Connection = objConnection
objCommand.CommandText = "select au_id,au_lname,au_fname from authors"
Dim dataAdaptor As New SqlDataAdapter
dataAdaptor.SelectCommand = objCommand
dataAdaptor.SelectCommand.Connection = objConnection
dataAdaptor.Fill(ds, "auth")
DataTable = ds.Tables("auth")
currRec = 0
totalRec = DataTable.Rows.Count
txtId.Text = DataTable.Rows(currRec)("au_id").ToString()
txtLast.Text = DataTable.Rows(currRec)("au_lname").ToString()
txtFirst.Text = DataTable.Rows(currRec)("au_fname").ToString()
End Sub
I have already checked with the SQl server logins and right..Everything is okay..A similar code works on my friends machine..what could be the reason
Last edited: