Database.
-
Hello Adil, you can use OleDbConnection, for e.g using System.Data.OleDb; //... //... //... OledbConnection conn = new OleDbConnection("your connection string here"); //... but maybe you should be more specific. what exactly do you want to do with the data? bind to a grid?... Also, what version of Asp.Net
acodeisacodeisacode
-
Hello Adil, you can use OleDbConnection, for e.g using System.Data.OleDb; //... //... //... OledbConnection conn = new OleDbConnection("your connection string here"); //... but maybe you should be more specific. what exactly do you want to do with the data? bind to a grid?... Also, what version of Asp.Net
acodeisacodeisacode
hi dear I was trying to use following code ..but it is not working properly. Imports System.Data.OleDb Public Class Form1 Inherits System.Windows.Forms.Form Dim cn As OleDbConnection Dim cmd As OleDbCommand Dim dr As OleDbDataReader Private Sub Form1_Load(ByVal sender As System.Object, ByVal e as _ System.EventArgs) Handles MyBase.Load End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As_ System.EventArgs) Handles Button1.Click Try cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;_ Data Source=C:\emp.mdb;") 'provider to be used when working with access database cn.Open() cmd = New OleDbCommand("select * from table1", cn) dr = cmd.ExecuteReader While dr.Read() TextBox1.Text = dr(0) TextBox2.Text = dr(1) TextBox3.Text = dr(2) ' loading data into TextBoxes by column index End While Catch End Try dr.Close() cn.Close() End Sub End Class regards adil
-
hi dear I was trying to use following code ..but it is not working properly. Imports System.Data.OleDb Public Class Form1 Inherits System.Windows.Forms.Form Dim cn As OleDbConnection Dim cmd As OleDbCommand Dim dr As OleDbDataReader Private Sub Form1_Load(ByVal sender As System.Object, ByVal e as _ System.EventArgs) Handles MyBase.Load End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As_ System.EventArgs) Handles Button1.Click Try cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;_ Data Source=C:\emp.mdb;") 'provider to be used when working with access database cn.Open() cmd = New OleDbCommand("select * from table1", cn) dr = cmd.ExecuteReader While dr.Read() TextBox1.Text = dr(0) TextBox2.Text = dr(1) TextBox3.Text = dr(2) ' loading data into TextBoxes by column index End While Catch End Try dr.Close() cn.Close() End Sub End Class regards adil
-
hi dear I was trying to use following code ..but it is not working properly. Imports System.Data.OleDb Public Class Form1 Inherits System.Windows.Forms.Form Dim cn As OleDbConnection Dim cmd As OleDbCommand Dim dr As OleDbDataReader Private Sub Form1_Load(ByVal sender As System.Object, ByVal e as _ System.EventArgs) Handles MyBase.Load End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As_ System.EventArgs) Handles Button1.Click Try cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;_ Data Source=C:\emp.mdb;") 'provider to be used when working with access database cn.Open() cmd = New OleDbCommand("select * from table1", cn) dr = cmd.ExecuteReader While dr.Read() TextBox1.Text = dr(0) TextBox2.Text = dr(1) TextBox3.Text = dr(2) ' loading data into TextBoxes by column index End While Catch End Try dr.Close() cn.Close() End Sub End Class regards adil
Hi Adil, You said something about ASP.Net but it looks like it is a windows form you are dealing with. Anyhow, it doesn't matter. What you can do is put a breakpoint in your code for the Button click event Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As_ System.EventArgs) Handles Button1.Click then step though the code and find out where it breaks. This would give us info enough to help you. Meanwhile, i expect that the database has a table, Table1 with at least 3 fields that are all of Text type (?). (gain maybe it would help for you to go with: TextBox1.Text = dr(0).ToString().....etc
acodeisacodeisacode