ASP.NET og MySQL problem
Mit problem er at jeg godt kan connecte til min mysql og faa det hele til at virke fra min localhost, men naar jeg uploader til min side saa fejler den og i trace skriver den det hertrace
ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
at System.Data.Odbc.OdbcConnection.HandleError(OdbcHandle hrHandle, RetCode retcode)
at System.Data.Odbc.OdbcConnectionHandle..ctor(OdbcConnection connection, OdbcConnectionString constr, OdbcEnvironmentHandle environmentHandle)
at System.Data.Odbc.OdbcConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningObject)
at System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup)
at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
at System.Data.Odbc.OdbcConnection.Open()
at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable)
at System.Web.UI.WebControls.SqlDataSourceView.ExecuteSelect(DataSourceSelectArguments arguments)
at System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback)
at System.Web.UI.WebControls.DataBoundControl.PerformSelect()
at System.Web.UI.WebControls.BaseDataBoundControl.DataBind()
at System.Web.UI.WebControls.DetailsView.DataBind()
at System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound()
at System.Web.UI.WebControls.DetailsView.EnsureDataBound()
at System.Web.UI.WebControls.CompositeDataBoundControl.CreateChildControls()
at System.Web.UI.Control.EnsureChildControls()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
end trace
er ret ny og ved ikke hvad jeg skal stille op.
min code
{
SqlDataSource Dashdatasource = new SqlDataSource();
Dashdatasource.ConnectionString = ConfigurationManager.ConnectionStrings["DashConnectionString1"].ToString();
Dashdatasource.InsertCommandType = SqlDataSourceCommandType.Text;
Dashdatasource.InsertCommand = "INSERT into News_main (Header, IPAddress, Writer, Text) VALUES (@Header, @IPAddress, @Writer, @Text)";
Dashdatasource.InsertParameters.Add("Header", TxtHeader.Text);
Dashdatasource.InsertParameters.Add("Text", TxtNews.Text);
Dashdatasource.InsertParameters.Add("Writer", User.Identity.Name);
Dashdatasource.InsertParameters.Add("IPAddress", Request.UserHostAddress.ToString());
//Dashdatasource.InsertParameters.Add("DateTimeStamp", DateTime.Now.ToString());
int rowsaffected = 0;
try
{
rowsaffected = Dashdatasource.Insert();
}
catch (Exception ex)
{
Server.Transfer("News_Problem.aspx");
}
finally
{
Dashdatasource = null;
}
if (rowsaffected != 1)
{
Server.Transfer("News_Problem.aspx");
}
else
{
Server.Transfer("News_Confirm.aspx");
}
}
}
end code
db mysql
table News_main
Feltnavn Datatype Kollation (Collation) Attributter Nulværdi Standardværdi Ekstra Handling
ID int(11) Nej auto_increment
IPAddress varchar(15) latin1_danish_ci Ja Not logged.
Writer tinytext latin1_danish_ci Nej
Date timestamp Nej CURRENT_TIMESTAMP
Header tinytext latin1_danish_ci Nej
Text varchar(255) latin1_danish_ci Nej
end
Og et lille ekstra spQrgsmaal.
kan man bruge asp.net komponenterne create user, login osv sammen med MySQL? hvis ja kan du saa give et eksempel, hvis nej har du saa andet bud paa hvad jeg kan gQre?