Click to See Complete Forum and Search --> : Connecting and creating a database


chinuaodi
August 15th, 2011, 05:01 PM
How do i create a database and input values into it ?. I can't connect to the database maybe i'm not putting up the right syntax, but when i run this program it gives me an SqlException error. it tells me i can't login into the database and it highlights this part of the code "dataAdapter.Fill(ds, "Article");"
int currRec = 0;
int totalRec = 0;
SqlConnection conn;
SqlDataAdapter dataadapter;
DataSet ds;

private void btnLoadTable_Click(object sender, EventArgs e)
{
this.Cursor = Cursors.WaitCursor;
string connection = "server = boss, database = newdatabase, uid=sa,pwd=;";
conn = new SqlConnection(connection);
string command = "select * from Article";
dataadapter = new SqlDataAdapter(command, conn);
ds = new DataSet();
dataAdapter.Fill(ds, "Article");
datatable = ds.Tables["Article"];
currRec = 0;
totalRec = datatable.Rows.Count;
FillControls();
initializingCommands();
toggleControls(true);
btnNext.Enabled = true;
btnPrevious.Enabled = true;
this.Cursor = Cursors.Default;

}
private void FillControls()
{
tbxArticleID.Text = datatable.Rows[currRec]["ArticleID"].ToString();
tbxArticleTitle.Text = datatable.Rows[currRec]["ArticleTitle"].ToString();
tbxTopic.Text = datatable.Rows[currRec]["Topic"].ToString();
tbxAuthorID.Text = datatable.Rows[currRec]["AuthorID"].ToString();
tbxAuthorName.Text = datatable.Rows[currRec]["AuthorName"].ToString();
tbxNoOfLines.Text = datatable.Rows[currRec]["NoOfLines"].ToString();
tbxDateOfPublishing.Text = datatable.Rows[currRec]["DateOfPublishing"].ToString();
}

reply pls ASAP. This is ma bb pin(21C1A7A6) i need gurus as friends. Tnx