Database ASP.Net question

kitty_meo12

New Member
First day on asp.net and got the file upload page to work, however, I want to connect to a database and I understand that its not exactly the same as it was in asp 3.0 . <BR><BR>Does anyone have a good example or a good website reference where I could see the code of how it is done? Basicall I need to know how to open the connection to a Microsoft access database that is stored in a database folder in my root directory. then how to build and execute the sql. then close the connection.<BR><BR>any help/references would be greatly appreciated.<BR><BR>MikeThis was courtesy of Scott Mitchell on this site in an article:<BR><BR>'Create a connection string<BR> Dim connString as String<BR> connString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE="path odbfile.mdb;"<BR> 'Open a connection<BR> Dim objConnection as OleDbConnection = New OleDbConnection(connString)<BR><BR> objConnection.Open()<BR><BR> 'Specify the SQL string<BR> Dim strSQL as String = "SELECT first,name FROM students where schcode = 'WHS' order by name"<BR><BR> 'Create a command object<BR> Dim objCommand as OleDbCommand<BR> objCommand = New OleDbCommand(strSQL, objConnection)<BR><BR> 'Get a datareader<BR> Dim objDataReader as OleDbDataReader<BR> objDataReader = objCommand.ExecuteReader(CommandBehavior.CloseConn ection)<BR><BR> 'Do the DataBinding<BR> dgResults.DataSource = objDataReader<BR> dgResults.DataBind()<BR><BR><BR> 'Close the datareader/db connection<BR> objDataReader.Close()<BR><BR>for me, dgResults was a datagrid. I'm having trouble getting individual items from the query outside the data grid. Can you help me with that??
 
Back
Top