| | |
Store data in variables
Please support our VB.NET advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved |
0
#2 Oct 22nd, 2009
Post the code where you are executing the
select * from table . There are a number of ways to go about this. •
•
Join Date: Sep 2009
Posts: 18
Reputation:
Solved Threads: 1
0
#3 Oct 22nd, 2009
OK, am having something like this:
VB.NET Syntax (Toggle Plain Text)
............................. ............................. Dim SQLConn As New SqlConnection Dim SQLCmd As New SqlCommand SQLConn.ConnectionString = ConnStr SQLConn.Open() SQLStr = "use Institution" 'This is my database SQLCmd.CommandText = SQLStr SQLCmd.Connection = SQLConn SQLCmd.ExecuteNonQuery() SQLStr = "Select * from Stud_Details where 1" SQLCmd.CommandText = SQLStr SQLCmd.Connection = SQLConn SQLCmd.ExecuteNonQuery() 'The problem begins here! Is it OK?
0
#4 Oct 22nd, 2009
No .. that isn't ok. You need to load the results in to a
Example:
DataTable using a SqlDataReader created by calling SqlCommand.ExecuteReader() .Example:
VB.NET Syntax (Toggle Plain Text)
private void button3333_Click(object sender, EventArgs e) { const string connStr = "Data Source=apex2006sql;Initial Catalog=Leather;Integrated Security=True;"; const string query = "Select * From Invoice (NOLOCK)"; DataTable dt; using (SqlConnection conn = new SqlConnection(connStr)) { conn.Open(); using (SqlCommand cmd = new SqlCommand(query, conn)) { using (SqlDataReader dr = cmd.ExecuteReader()) { dt = new DataTable(); dt.Load(dr); //This loads a table } } conn.Close(); } MessageBox.Show(string.Format("You have {0:F0} rows", dt.Rows.Count)); }
![]() |
Similar Threads
- how to store data from com port to access in vb.net (VB.NET)
- Store Data at Access database (C#)
- sql vs xml to store data (MS SQL)
- how to store data from VB to MSaccess (Visual Basic 4 / 5 / 6)
- How to store data in data grid to database by single mouse click in Asp.net (ASP.NET)
- how to store the data? (Java)
Other Threads in the VB.NET Forum
- Previous Thread: Setup Project - shortcut options?
- Next Thread: VB.Net Networking Heartbeat
Views: 314 | Replies: 4
| Thread Tools | Search this Thread |
Tag cloud for VB.NET
"crystal .net 2008 access add advanced application array assignment basic box button buttons center class click code combo convert cpu data database datagrid datagridview design designer dissertation dissertations dosconsolevb.net editvb.net employees excel exists firewall forms function images isnumericfuntioncall listview map math memory mobile module msaccess mssqlbackend mysql navigate net number opacity page pan picturebox picturebox2 port print printing printpreview problem record refresh regex reuse richtextbox right-to-left save search serial socket sorting sqldatbase sqlserver storedprocedure structures studio temp textbox timer txttoxmlconverter upload useraccounts usercontol vb vb.net vb.nettoolboxvisualbasic2008sidebar vb2008 vba vbnet vista visual visualbasic visualbasic.net visualstudio.net visualstudio2008 web winsock wpf wrapingcode xml






