Click here to Skip to main content
16,014,392 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Restarting a socket Pin
Kiran Kumar B29-May-07 17:44
Kiran Kumar B29-May-07 17:44 
GeneralRe: Restarting a socket Pin
Diego F.29-May-07 21:50
Diego F.29-May-07 21:50 
QuestionCrystal Report Takes too Much Time Pin
Rupesh Kumar Swami28-May-07 22:13
Rupesh Kumar Swami28-May-07 22:13 
AnswerRe: Crystal Report Takes too Much Time Pin
Steven J Jowett28-May-07 23:14
Steven J Jowett28-May-07 23:14 
GeneralRe: Crystal Report Takes too Much Time Pin
Rupesh Kumar Swami29-May-07 0:29
Rupesh Kumar Swami29-May-07 0:29 
QuestionImporting COM Components Pin
Zaegra28-May-07 21:18
Zaegra28-May-07 21:18 
AnswerRe: Importing COM Components Pin
CPallini29-May-07 2:04
mveCPallini29-May-07 2:04 
Questionconnection problem Pin
matjame28-May-07 21:11
matjame28-May-07 21:11 
Im trying to connect to my database for some values but I keep getting the message that the connection is already open.But I cant see where.("The Microsoft Jet database engine cannot open the file 'C:\Documents and Settings\kagisho.mashiloane\My Documents\WORK\2006\WebStu\TryCsharp'. It is already opened exclusively by another user, or you need permission to view its data.")

HERE IS THE CODE:

using System;
using System.Data;
//using System.Data.SqlClient if using sqlserver db
using System.Data.OleDb; //added
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;


public partial class ViewGrid : System.Web.UI.Page
{
OleDbConnection con;
//string ConnectionString = "Provider = Microsoft.jet.oledb.4.0; Data source = C:\u005CWebStu\\TryCsharp\\NWINDAllowUpdate.mdb";
string ConnectionString = "Provider = Microsoft.jet.oledb.4.0; Data source = C:\\Documents and Settings\\kagisho.mashiloane\\My Documents\\WORK\\2006\\WebStu\\TryCsharp";
string CommandText = "select EmployeeId, FirstName, LastName from Employees";
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
//con.Close();***************************************
//
// Loads the Employees grid


con = new OleDbConnection(ConnectionString);
OleDbCommand cm = new OleDbCommand(CommandText, con);
******PROBLEM IS HERE con.Open(); GridView1.DataSource = cm.ExecuteReader(CommandBehavior.CloseConnection);
GridView1.DataBind();



//Loads the Dropdown listbox with Unique countries
// from the Suppliers table

string str = "Select Distinct Country from Suppliers";
//if (con.State == ConnectionState.Closed
// {
// con.Open();
// }
OleDbCommand cm2 = new OleDbCommand(str,con);
OleDbDataReader dtr = cm2.ExecuteReader();

while(dtr.Read())
{
ddlCountries.Items.Add(dtr.GetString(0));

}
dtr.Close();
}

}





protected void ddlCountries_SelectedIndexChanged(object sender, EventArgs e)
{
string str = "Select SupplierId, Country, CompanyName from Suppliers where Country = '" + ddlCountries.SelectedItem + "'";
con = new OleDbConnection(ConnectionString);
OleDbCommand cm = new OleDbCommand(str, con);

con.Open();

GridView2.DataSource = cm.ExecuteReader(CommandBehavior.CloseConnection);
GridView2.DataBind();
}

}



kagiso

AnswerRe: connection problem Pin
WhiteGirl2328-May-07 23:05
WhiteGirl2328-May-07 23:05 
GeneralRe: connection problem Pin
matjame28-May-07 23:15
matjame28-May-07 23:15 
AnswerRe: connection problem Pin
Navneet Hegde29-May-07 0:47
Navneet Hegde29-May-07 0:47 
GeneralRe: connection problem Pin
matjame29-May-07 0:53
matjame29-May-07 0:53 
GeneralRe: connection problem Pin
Navneet Hegde29-May-07 1:03
Navneet Hegde29-May-07 1:03 
AnswerRe: connection problem Pin
ne0h29-May-07 0:47
ne0h29-May-07 0:47 
QuestionUsing Crystal Report 9 application and .Net Crystal Report application at same machine Pin
Ali 11028-May-07 21:01
Ali 11028-May-07 21:01 
QuestionFetching Undelivered Mail From Outllook Through ASP.NET 2.0 Pin
varshavmane28-May-07 20:34
varshavmane28-May-07 20:34 
QuestionFile/Folder security vb.net 2005 [modified] Pin
Sonia Gupta28-May-07 19:20
Sonia Gupta28-May-07 19:20 
AnswerRe: File/Folder security vb.net 2005 Pin
Dave Kreskowiak29-May-07 4:11
mveDave Kreskowiak29-May-07 4:11 
Questionproblem in reading xml element Pin
balakpn28-May-07 18:30
balakpn28-May-07 18:30 
AnswerRe: problem in reading xml element Pin
Christian Graus28-May-07 23:14
protectorChristian Graus28-May-07 23:14 
QuestionUnable to capture the click event of a device using WIA 2.0 Pin
shivals28-May-07 18:30
shivals28-May-07 18:30 
QuestionHow to set up and correctly use the GetPositionFromCharIndex() Statement in VB.net?? Pin
josh047628-May-07 17:30
josh047628-May-07 17:30 
AnswerRe: How to set up and correctly use the GetPositionFromCharIndex() Statement in VB.net?? Pin
TwoFaced28-May-07 18:45
TwoFaced28-May-07 18:45 
QuestionSend SMS error Pin
Socheat.Net28-May-07 15:47
Socheat.Net28-May-07 15:47 
AnswerRe: Send SMS error Pin
Sathesh Sakthivel28-May-07 15:54
Sathesh Sakthivel28-May-07 15:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.