| | |
Datagrid view using parameters(Plz help)
Please support our VB.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Jun 2007
Posts: 23
Reputation:
Solved Threads: 0
HI all .....
I am beginner of VB. net. I m developing a vb.net application program to store, update and search contact information and address. I have completed the data. I have used ms access as my backend. I enter data like wise;
And to search these type of data i have used separate forms by providing the links of forms in an one search form.
I have given parameters like name, country, org, email to search the contact. I need to show them in a data grid in the form. suppose i insert name in the text box and press button search then the resembling names and their information should be displayed in the data grid. I would be very grateful if anyone helps me to solve this problem.
Waiting for the replys.
Sincerly
Kshiteesh
I am beginner of VB. net. I m developing a vb.net application program to store, update and search contact information and address. I have completed the data. I have used ms access as my backend. I enter data like wise;
vb.net Syntax (Toggle Plain Text)
Dim con As New ADODB.Connection Dim tmp As New ADODB.Recordset Dim s As String con.ConnectionString = "provider=microsoft.jet.oledb.4.0;data source=K:\Database\db1.mdb" con.Open() s = "select * from add1" tmp.Open(s, con, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockPessimistic) . . . tmp.AddNew() tmp.Fields("ID").Value = T18.Text MsgBox("Record Saved") Exit Sub
And to search these type of data i have used separate forms by providing the links of forms in an one search form.
I have given parameters like name, country, org, email to search the contact. I need to show them in a data grid in the form. suppose i insert name in the text box and press button search then the resembling names and their information should be displayed in the data grid. I would be very grateful if anyone helps me to solve this problem.
Waiting for the replys.
Sincerly
Kshiteesh
Hi,
Check this Code:
Add a Datgrid to ur Form.

REgards
Veena
Check this Code:
Add a Datgrid to ur Form.
VB.NET Syntax (Toggle Plain Text)
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load dim sSQL As String Dim DA As OleDbDataAdapter Dim DS As DataSet Dim ConnStr As String ="Your Connection String" sSQL = "SELECT * FROM MyTable" DA = New OleDbDataAdapter(sSQL, ConnStr) DS = New DataSetDA.Fill(DS, "TabName") DatGrid1.DataSource = DS.Tables("TabName") End Sub

REgards
Veena
Last edited by QVeen72; Aug 2nd, 2007 at 6:35 am.
•
•
Join Date: Aug 2007
Posts: 2
Reputation:
Solved Threads: 0
"to save data in the sql server write this code"
Private Sub button_save(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button.save
dim cmd = new sqlcommand("insert into table_name values('"& txtname.txt & "')",con)
dim ds as dataset
dim da as sqldataadaptor(cmd)
com.executenonquery
msgbox"saved"
"and for diaplay in datagrid please write this code on the form load event"
dim cmd = new sqlcommand("select * from table_name",con)
dim ds as dataset
dim da as sqldataadaptor(cmd)
da.fill(ds,"table_ name")
datagrid1.datasource = "TabName"
datagrid1.datamember= ds
Private Sub button_save(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button.save
dim cmd = new sqlcommand("insert into table_name values('"& txtname.txt & "')",con)
dim ds as dataset
dim da as sqldataadaptor(cmd)
com.executenonquery
msgbox"saved"
"and for diaplay in datagrid please write this code on the form load event"
dim cmd = new sqlcommand("select * from table_name",con)
dim ds as dataset
dim da as sqldataadaptor(cmd)
da.fill(ds,"table_ name")
datagrid1.datasource = "TabName"
datagrid1.datamember= ds
just use the sql -query (in submit button click)i.e
dim str as string="select * from tablename where Name ="' & name_txt.text & "'
so the above query -should work when u enter a particular name in textbox called(name_txt)&.
Then all the records related to that name -should b displayed on datagrid or textbox on the form,,,,
regards,
preetham...
dim str as string="select * from tablename where Name ="' & name_txt.text & "'
so the above query -should work when u enter a particular name in textbox called(name_txt)&.
Then all the records related to that name -should b displayed on datagrid or textbox on the form,,,,
regards,
preetham...
•
•
Join Date: Jun 2007
Posts: 23
Reputation:
Solved Threads: 0
Thank you for the reply ......
I did as you said QVeen 72 but it asks oledbdataadapter to be defined and it doesnot recognises new dataset ds it posts an error when you post
It also asks datagrid1 to be declared....I m a bit vague on it. I declared datagrid1 as datagrid in the load event and
but the problem still persists...
Please help me wot to do????
I did as you said QVeen 72 but it asks oledbdataadapter to be defined and it doesnot recognises new dataset ds it posts an error when you post
VB.NET Syntax (Toggle Plain Text)
DS = New DataSetDA.Fill(DS, "TabName")
It also asks datagrid1 to be declared....I m a bit vague on it. I declared datagrid1 as datagrid in the load event and
VB.NET Syntax (Toggle Plain Text)
Dim DA As OleDb.OleDbDataAdapter
Please help me wot to do????
•
•
Join Date: Jun 2007
Posts: 23
Reputation:
Solved Threads: 0
Hi frens.
Thank you for the help
You gave the code for saving and displaying data in datagrid in SQL.
However, I have MS Access in backend so I faced certain difficulties in it. I also followed Queen V's instructions but it didn't solve my problem. Please Help so that I can do it well.
Please help wot is the problem with my code.
Anticipating ur replies.
Kshiteesh
Thank you for the help
You gave the code for saving and displaying data in datagrid in SQL.
However, I have MS Access in backend so I faced certain difficulties in it. I also followed Queen V's instructions but it didn't solve my problem. Please Help so that I can do it well.
VB.NET Syntax (Toggle Plain Text)
Private Sub name_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim con As New ADODB.Connection Dim tmp As New ADODB.Recordset Dim s As String Dim DA As New OleDb.OleDbDataAdapter Dim oledbdataadapter1 As OleDb.OleDbDataAdapter Dim db1dataset1 As New DataSet Dim DS As DataSet Dim datagrid1 As New DataGrid con.ConnectionString = "provider=microsoft.jet.oledb.4.0;data source=K:\Database\db1.mdb" con.Open() s = "SELECT * FROM MyTable where fname='" & TextBox1.Text & "'" DA = New OleDb.OleDbDataAdapter(s, con, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockPessimistic) DS = New db1DataSet1.add1Row(DS, "add1") DatGrid1.DataSource = DS.Tables("add1") End Sub
Please help wot is the problem with my code.
Anticipating ur replies.
Kshiteesh
your code seems to be missing the Fill command for the datagrid
Let us know which part of the code is the error thrown up.
VB.NET Syntax (Toggle Plain Text)
DataGrid1.Fill(ds,"add1")
Let us know which part of the code is the error thrown up.
There is just two ways to live your life.
One is as though nothing is a miracle.
The other is as if everything is.
One is as though nothing is a miracle.
The other is as if everything is.
•
•
Join Date: Jun 2007
Posts: 23
Reputation:
Solved Threads: 0
Dear frens,
I m still facing the same problem, I m using VB.net 2007. when i use
In the aforementioned code I get problem when I write
it shows build error showing
end of statement expected
and
shows build error showing
'fill' is not a member of 'System.Windows.Forms.DataGrid'.
I don get any point please help me...and please explain how to overcome this problem. I don't have much time coz most of my time has been lost in this problem.
please help
I m still facing the same problem, I m using VB.net 2007. when i use
VB.NET Syntax (Toggle Plain Text)
Private Sub name_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim s As String Dim tmp As ADODB.Recordset Dim ds As New DataSet Dim datagrid1 As New DataGrid Dim dataview As New DataView Dim da As New OleDb.OleDbDataAdapter Dim ds1 As New DataSet con.ConnectionString = "provider=microsoft.jet.oledb.4.0;data source=K:\Database\db1.mdb" con.Open() s = "select * from add1 where fname='" & TextBox1.Text & "'" tmp.Open(s, con, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockPessimistic) Dim ConnStr As String = "provider=microsoft.jet.oledb.4.0;data source=K:\Database\db1.mdb""" da = New OleDb.OleDbDataAdapter(s, ConnStr) ds = New DataSet da.fill(ds, add1") datagrid1.DataSource = ds.Tables("add1") datagrid1.fill(da, "add1") End Sub
In the aforementioned code I get problem when I write
VB.NET Syntax (Toggle Plain Text)
ds = New DataSet da.fill(ds, add1")
end of statement expected
and
VB.NET Syntax (Toggle Plain Text)
datagrid1.fill(da, "add1")
'fill' is not a member of 'System.Windows.Forms.DataGrid'.
I don get any point please help me...and please explain how to overcome this problem. I don't have much time coz most of my time has been lost in this problem.
please help
Hi,
Sorry that was C code not vb
And Recordset Object does exist in VB.net..
check this :
Regards
Veena
Sorry that was C code not vb
And Recordset Object does exist in VB.net..
check this :
VB.NET Syntax (Toggle Plain Text)
Dim conStr As String = "Provider=Microsoft.JET.OLEDB.4.0;data source=K:\Database\db1.mdb" Dim conn As OleDbConnection = New OleDbConnection(conStr) Dim Ssql As String ssql = "select * from add1 where fname='" & TextBox1.Text & "'" Dim da As OleDbDataAdapter = New OleDbDataAdapter(Ssql, conn) Dim ds As New DataSet da.Fill(ds, "Table1") DataGrid1.DataSource = ds.DefaultViewManager
Regards
Veena
Last edited by QVeen72; Aug 7th, 2007 at 10:08 am.
•
•
Join Date: Jun 2007
Posts: 23
Reputation:
Solved Threads: 0
Dear frens and especially the ones who have helped me. Hi to all...
The code in form to show data in the data grid is as follows.
But when i tryto run it then it runs and when i click then it shows the InvalidOperationException was unhandled showing error msg.
how can i overcome this problem
please please...anyone who sees this thread...able to help me ...reply........whether it be VEENA, Preetam, Arjun, Kap or any other else.......
I would truely appereciate your great help..
Anticipating the replies...
Regards
Kshiteesh
The code in form to show data in the data grid is as follows.
But when i tryto run it then it runs and when i click then it shows the InvalidOperationException was unhandled showing error msg.
VB.NET Syntax (Toggle Plain Text)
{"The SelectCommand property has not been initialized before calling 'Fill'."}
how can i overcome this problem
vb.net Syntax (Toggle Plain Text)
Public Class name Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click [inlinecode] Dim oledbdataadapter1 As New OleDb.OleDbDataAdapter Db1DataSet1.Clear() oledbdataadapter1.Fill(Db1DataSet1) [/inlinecode] End Sub Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click End Sub Private Sub name_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'TODO: This line of code loads data into the 'Db1DataSet1.add1' table. You can move, or remove it, as needed. [inlinecode]Me.Add1TableAdapter.Fill(Me.Db1DataSet1.add1) Dim conStr As String = "Provider=Microsoft.JET.OLEDB.4.0;data source=K:\Database\db1.mdb" Dim con As OleDb.OleDbConnection = New OleDb.OleDbConnection(conStr) Dim S As String Dim datagrid1 As New DataGrid S = "select * from add1 where fname='" & TextBox1.Text & "'" Dim da As OleDb.OleDbDataAdapter = New OleDb.OleDbDataAdapter(S, con) da.Fill(Db1DataSet1, "add1") datagrid1.DataSource = Db1DataSet1.DefaultViewManager [/inlinecode] End Sub Private Sub Db1DataSet1_Initialized(ByVal sender As Object, ByVal e As System.EventArgs) End Sub Private Sub DataGridView1_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) End Sub Private Sub DataGridView1_CellContentClick_1(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellContentClick End Sub Private Sub Add1BindingSource_CurrentChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Add1BindingSource.CurrentChanged End Sub Private Sub FNameDataGridViewTextBoxColumn_Disposed(ByVal sender As Object, ByVal e As System.EventArgs) Handles FNameDataGridViewTextBoxColumn.Disposed End Sub End Class
please please...anyone who sees this thread...able to help me ...reply........whether it be VEENA, Preetam, Arjun, Kap or any other else.......
I would truely appereciate your great help..
Anticipating the replies...
Regards
Kshiteesh
![]() |
Similar Threads
- using summation and aggregate expressions on datagrid/view (ASP.NET)
- problem with entering data in datagrid (VB.NET)
- prblem:use a control in datagrid (ASP.NET)
- Simple ASP.Net Login Page (Using VB.Net) (ASP.NET)
Other Threads in the VB.NET Forum
- Previous Thread: update& retrieve images from sql server using vb.net
- Next Thread: anurag agarwal
| Thread Tools | Search this Thread |
.net .net2008 2008 access account add advanced application array basic beginner browser button buttons click code combo cpu cuesent data database datagrid datagridview date datetimepicker designer dissertation dissertations dissertationtopic employees excel exists fade filter forms generatetags html images input intel internet listview mobile module monitor mysql net number objects open panel passingparameters pdf picturebox picturebox2 port position print printing printpreview problem regex reuse right-to-left save search searchvb.net select serial settings shutdown socket sqldatbase sqlserver storedprocedure survey temperature textbox timer timespan transparency txttoxmlconverter update user usercontol vb vb.net vb.netformclosing()eventpictureboxmessagebox vbnet vista visual visualbasic.net visualstudio.net visualstudio2008 web winforms wpf wrapingcode xml year





