G
Guest
Hello,
Thanks in advance for any insight you can offer. I've a ASP.NET project
written in C#, two web forms, a lovely gob of using statements. I originally
had one webform with all my fields and datagrid stacked, and thought it would
be cleaner to server.transfer to another webform when I wanted to submit a
new record. When I had just one webform this same syntax worked fine. But now
that I'm not on the same webform as where the datagrid resides, I had to
change the code to use a sqlCommand. I am not presently getting an error, and
it builds fine. (By the way, I did turn off the custom error messages but it
doesn't give me the full error page.)
Earlier on I was getting errors like 'input string not in correct format',
but those seemed to have cleared. I also got an error that was a null object
reference and I seem to have resolved that too.
again thanks,
Samantha
try
{
SqlConnection sqlCon6 = new SqlConnection(
"Server=DP05900;database=InfoSvcs_ServerLogs;uid=sa;password=cr3ati0n;");
SqlCommand sqlAddLog = new SqlCommand ("sqlAddLog", sqlCon6);
sqlCon6.Open();
sqlAddLog.CommandType = CommandType.StoredProcedure;
sqlAddLog.CommandText = ("exec sqlAddLog");
sqlAddLog.Parameters.Add("@Assigned_To",System.Data.SqlDbType.VarChar,20).Value = ddlAdmins.SelectedItem.Text; ;
sqlAddLog.Parameters.Add("@Entry_Date_Time",System.Data.SqlDbType.DateTime, 8).Value = TxtDate.Text;
sqlAddLog.Parameters.Add("@Comments",System.Data.SqlDbType.VarChar,5000).Value = TxtAction.Text;
sqlAddLog.Parameters.Add("@Server_Id",System.Data.SqlDbType.Int).Value =
ddlServers.SelectedValue;
Console.WriteLine();
sqlCon6.Close();
// Server.Transfer ("ControlPanel.aspx");
}
catch ( System.Exception Ex )
{
Console.WriteLine();
LblError.Text =
Ex.Message;
}
finally
{
if (sqlCon6 != null)
sqlCon6.Close();
}
}
Thanks in advance for any insight you can offer. I've a ASP.NET project
written in C#, two web forms, a lovely gob of using statements. I originally
had one webform with all my fields and datagrid stacked, and thought it would
be cleaner to server.transfer to another webform when I wanted to submit a
new record. When I had just one webform this same syntax worked fine. But now
that I'm not on the same webform as where the datagrid resides, I had to
change the code to use a sqlCommand. I am not presently getting an error, and
it builds fine. (By the way, I did turn off the custom error messages but it
doesn't give me the full error page.)
Earlier on I was getting errors like 'input string not in correct format',
but those seemed to have cleared. I also got an error that was a null object
reference and I seem to have resolved that too.
again thanks,
Samantha
try
{
SqlConnection sqlCon6 = new SqlConnection(
"Server=DP05900;database=InfoSvcs_ServerLogs;uid=sa;password=cr3ati0n;");
SqlCommand sqlAddLog = new SqlCommand ("sqlAddLog", sqlCon6);
sqlCon6.Open();
sqlAddLog.CommandType = CommandType.StoredProcedure;
sqlAddLog.CommandText = ("exec sqlAddLog");
sqlAddLog.Parameters.Add("@Assigned_To",System.Data.SqlDbType.VarChar,20).Value = ddlAdmins.SelectedItem.Text; ;
sqlAddLog.Parameters.Add("@Entry_Date_Time",System.Data.SqlDbType.DateTime, 8).Value = TxtDate.Text;
sqlAddLog.Parameters.Add("@Comments",System.Data.SqlDbType.VarChar,5000).Value = TxtAction.Text;
sqlAddLog.Parameters.Add("@Server_Id",System.Data.SqlDbType.Int).Value =
ddlServers.SelectedValue;
Console.WriteLine();
sqlCon6.Close();
// Server.Transfer ("ControlPanel.aspx");
}
catch ( System.Exception Ex )
{
Console.WriteLine();
LblError.Text =
Ex.Message;
}
finally
{
if (sqlCon6 != null)
sqlCon6.Close();
}
}