|
* i have a column that store simages in my database
i make the image column type is (image)
so when i try to insert image into my data base message appear " u must use iconvertible"
what is that "iconvertible" and how to use it?!!!!!!!
* i make image column allow null so if i try to insert row without image message apear meaning i can't use null i must use dbnull.
what is the dbnull and how allow image column to be allow null with errors?!!
ma_refay
|
|
|
|
|
ma_refay wrote: * i have a column that store simages in my database
i make the image column type is (image)
so when i try to insert image into my data base message appear " u must use iconvertible"
what is that "iconvertible" and how to use it?!!!!!!!
I've never seen that error message - Are you passing the data as a byte array: byte[]
ma_refay wrote: * i make image column allow null so if i try to insert row without image message apear meaning i can't use null i must use dbnull.
what is the dbnull and how allow image column to be allow null with errors?!!
DBNull is used to signify a null in the database. In certain situations a null can be ambiguous. For example: I use ExecuteScalar and the result is null . Is it null because there is no data being returned, or is it null because the data I requested is a null value in the database? To disambiguate, all null s from the database are DBNull.Value
Scottish Developers events:
* .NET debugging, tracing and instrumentation by Duncan Edwards Jones and Code Coverage in .NET by Craig Murphy
* Developer Day Scotland: are you interested in speaking or attending?
My: Website | Blog
|
|
|
|
|
i use this code to store image in my database
*********************
Dim DR As DataRow
DR = Ds_products1.employees_dir_sp.NewRow
SqlInsertCommand1.Parameters("@emp_fname").Value = txtfname.Text
SqlInsertCommand1.Parameters("@emp_mname").Value = txtmname.Text
SqlInsertCommand1.Parameters("@emp_photo").Value = PictureBox1.Image
DR("emp_fname") = SqlInsertCommand1.Parameters("@emp_fname").Value
DR("emp_mname") = SqlInsertCommand1.Parameters("@emp_mname").Value
DR("emp_photo") = SqlInsertCommand1.Parameters("@emp_photo").Value
Ds_products1.employees_dir_sp.Rows.Add(DR)
da_empdir.Update(Ds_products1.employees_dir_sp)
************************************************
so when i click the save button that message apeear
"object must implement iconvertible"
ma_refay
|
|
|
|
|
|
|
I created a windows form in VS2005 that uses Enterprise Library - DAAB - version Jan 2006 to access the DB in its constructor. Everything works fine; however, when I created a UserControl that attempts to store that form as a variable, the VS 2005 designer will not let me drag that UserControl onto a new form. It gives me the following error:
“Failed to create component ‘UserControl’. The error message follows: ‘System.NullReferenceException: Object reference not set to an instance of object. At Microsoft.Practices.EnterpriseLibrary.Data.DatabaseConfigurationView.get_DefaultName(), at Microsoft.Practices.EnterpriseLibrary.Data.DatabaseMapper.MapName(String name, IConfigurationSource configSource)…….”
Everything compiles successfully without errors; however, I am unable to use the UserControl on any forms. After debugging, I found that the error is caused by the line “Database db = DatabaseFactory.CreateDatabase();” This line is standard DAAB code and is supposed to work and it does works in all cases I’ve run across EXCEPT this.
Is this a bug in the DAAB, or VS Designer, or am I missing something? Any help will be appreciated! Thanks in advance!
Below is the relevant code:
public partial class SampleControl : UserControl
{
private ProductForm subForm = new ProductForm();
public SampleControl ()
{
InitializeComponent();
}
}
public partial class ProductForm : Form
{
public ProductForm()
{
InitializeComponent();
AccessDB();
}
private void AccessDB()
{
//THIS LINE CAUSES THE DESIGNER ERROR
Database db = DatabaseFactory.CreateDatabase();
}
}
Thanks
|
|
|
|
|
I don't know how this relates to your problem - perhaps the full stack trace would be more helpful - but there are a number of things that stand out as being, at best, a little odd.
You are instatiating a form during the construction phase of your user control - Why do you need this form? Why not construct it just as you are about to use it? That would seem to be a better design.
Although you receive some kudos for using the Enterprise Library, you are not using it in a Dal - you're just dumping the data access in the form like the designer would - This is great for a simple throw away app you are only going to use one, but for an enterprise application data access should be tucked away in a DAL (Data Access Layer). The Enterprise Library DAAB on its own is not a DAL, it just makes the creation of a DAL much easier.
Scottish Developers events:
* .NET debugging, tracing and instrumentation by Duncan Edwards Jones and Code Coverage in .NET by Craig Murphy
* Developer Day Scotland: are you interested in speaking or attending?
My: Website | Blog
|
|
|
|
|
The problem is not with either the DAAB or the Visual Designer. They are functioning as intended and doing just what you are asking them to do.
The problem as Colin points out is with your design. When your control is being rendered in the designer it is trying to instantiate the form. Again, as Colin suggests, a better approach may be to remove the form from the creation process and move the DAAB to a DAL.
|
|
|
|
|
Folks,
We had a server crash, but were able to restore our database files from the disk. Having rebuilt our server, we would now like to restore the database, but we're unable to figure out to re-attach the .MDB file, as it was not detached prior to the crash.
We're using SQL v7.0.
Any help would be greatly appreciated.
TIA!
'til next we type...
HAVE FUN!! -- Jesse
|
|
|
|
|
Actually, it is an .mdf file - .mdb is a msaccess file extension.
You can use sp_attach_db , sp_attach_single_file_db , or even see here[^]
CREATE DATABASE [ATestDB] ON (FILENAME = 'C:\TestPath\ATestDB_Data.MDF') FOR ATTACH
----------
Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them.
- Laurence J. Peters
|
|
|
|
|
EricDV wrote: Actually, it is an .mdf file
Sorry, my bad...
EricDV wrote: You can use sp_attach_db, sp_attach_single_file_db
Per MSDN:
Remarks<br />
sp_attach_db should only be executed on databases that were previously detached from the database server using an explicit sp_detach_db operation.
As I mentioned in my post, the file(s) were not previously detached.
Here's what we've tried so far...
<br />
Attempt 1 (Strike 1): TRIED TO EXECUTE IN QUERY ANALYZER<br />
EXEC sp_attach_db @dbname = 'NewDatabase', <br />
@filename1 = 'c:\mssql7\data\ArchiveData.mdf', <br />
@filename2 = 'c:\mssql7\data\ArchiveLog.ldf'<br />
<br />
SERVER MESSAGES:<br />
Server: Msg 9004, Level 21, State 3, Line 1<br />
The log for database 'NewDatabase' is corrupt.<br />
Connection Broken<br />
<br />
(Continued) ISSUE:<br />
The log file is corrupt, so I tried to attach the mdf file to a new database using the single file attach method.<br />
<br />
Attempt 2 (Strike 2):TRIED TO EXECUTE IN QUERY ANALYZER<br />
EXEC sp_attach_single_file_db @dbname = 'NewDatabase', <br />
@physname = 'c:\mssql7\data\ArchiveData.mdf'<br />
<br />
SERVER MESSAGES:<br />
Server: Msg 945, Level 14, State 2, Line 1<br />
Database 'NewDatabase' cannot be opened because some of the files could not be activated.<br />
Server: Msg 1813, Level 16, State 2, Line 1<br />
Could not open new database 'NewDatabase'. CREATE DATABASE is aborted.<br />
<br />
Attempt 3 (Strike 3 --- Struck OUT): tried to fool SQL Server by switch mdf files. <br />
I created a brand new database called Archive.<br />
I detached the database.<br />
I renamed the Archive_Data.mdf to Archive_DataOld.mdf<br />
I applied the switch by renaming the AchiveData.mdf to Archive_Data.mdf <br />
I left the brand new log file alone.<br />
I attempted to attach the database<br />
<br />
EXEC sp_attach_db @dbname = 'Archive', <br />
@filename1 = 'c:\mssql7\data\Archive_Data.mdf', <br />
@filename2 = 'c:\mssql7\data\Archive_Log.ldf'<br />
<br />
<br />
also tried<br />
<br />
EXEC sp_attach_db @dbname = 'NewDatabase', <br />
@filename1 = 'c:\mssql7\data\Archive_Data.mdf', <br />
@filename2 = 'c:\mssql7\data\Archive_Log.ldf'<br />
<br />
SERVER MESSAGES:<br />
Changed language setting to us_english.<br />
Server: Msg 5173, Level 16, State 2, Line 1<br />
Cannot associate files with different databases.<br />
'til next we type...
HAVE FUN!! -- Jesse
|
|
|
|
|
Hi, I have an ASP.NET/C# application in which the user enters a part number, hits the command button and the grid populates info about that part.
I think something is wrong with my SQL statement, as when my grid loads in the page, data is showing before I've entered anything.
Here is a snippet of the code:
private void Page_Load(object sender, System.EventArgs e)
{<br />
if(!Page.IsPostBack)<br />
{<br />
BindData();<br />
}<br />
}<br />
private void BindData()<br />
{<br />
strPartNumberInputReference = txtPartNumberInput.Text;<br />
<br />
<br />
<br />
string SQLString = "SELECT p.PartNumber, pt.description, dd.DrawingNumber, dd.DrawingRevision, dd.DwgPath FROM parts p INNER JOIN PartTypes pt on pt.ID =p.PartTypeID LEFT JOIN DraftingData dd on dd.PartID = p.ID WHERE p.PartNumber = @PartID;SELECT w.weight, wt.Description AS wtDescription, p.PartNumber from weights w INNER JOIN weighttypes wt on wt.ID = w.weighttypeid INNER JOIN Parts p on w.PartID = p.ID;SELECT c.cost, p.PartNumber, ct.Description AS ctDescription from Costs c INNER JOIN Parts p ON c.PartID = p.Id INNER JOIN CostTypes ct on ct.Id = c.CostTypeID; SELECT s.SubPartID, s.Quantity, s.Sequence, p.PartNumber FROM SubParts s INNER JOIN Parts p ON s.PartID = p.Id "; <br />
<br />
SqlCommand cmd = new SqlCommand();<br />
cmd.Connection = new SqlConnection(strConnectSQL);<br />
cmd.CommandText = SQLString;<br />
cmd.Parameters.Add ("@PartID", strPartNumberInputReference);<br />
SqlDataAdapter adapter = new SqlDataAdapter(cmd);<br />
adapter.Fill(ds);<br />
<br />
ds.Tables[1].TableName = "Weights";<br />
ds.Tables[2].TableName = "Costs";<br />
ds.Tables[3].TableName = "Subparts";<br />
<br />
dgParts.DataSource = ds;<br />
dgParts.DataBind();<br />
txtPartNumberInput.Text = "";<br />
}
Does anyone see what I'm missing?eID LEFT JOIN parts p on p.id = w.PartID WHERE p.PartNumber = @PartID;SELECT c.cost, ct.Description AS ctDescription, p.PartNumber from Costs c INNER JOIN Parts p ON c.PartID = p.Id LEFT JOIN CostTypes ct on ct.Id = c.CostTypeId WHERE p.PartNumber = @PartID;SELECT s.SubPartId, s.Quantity, s.Sequence, p.PartNumber FROM SubParts s INNER JOIN Parts p ON s.PartID = p.Id";
SqlCommand cmd = new SqlCommand();
cmd.Connection = new SqlConnection(strConnectSQL);
cmd.CommandText = SQLString;
cmd.Parameters.Add ("@PartID", strPartNumberInputReference);
SqlDataAdapter adapter = new SqlDataAdapter(cmd);
adapter.Fill(ds);
ds.Tables[1].TableName = "Weights";
ds.Tables[2].TableName = "Costs";
ds.Tables[3].TableName = "Subparts";
dgParts.DataSource = ds;
dgParts.DataBind();
txtPartNumberInput.Text = "";
}
I've been going crazy with this. Can someone help me fix one or the other?
|
|
|
|
|
First, shouldn't you call your BindData() AFTER there is postback instead of BEFORE, i.e.
if(Page.IsPostBack)
{
BindData();
}
Second, you have four queries in your SQL statement, with the second to fourth queries not needing any parameters, which means whatever your PartNumberInput is they're still going to be displayed and always the same. I'm assuming whatever binds to your Tables[1] to Tables[3] will always be shown in this case.
Does that help?
"Democracy is two wolves and a sheep voting on what to have for dinner" - Ross
Edbert
Sydney, Australia
|
|
|
|
|
Okay, I think I know what you mean. Here is what I have now:
private void BindData()<br />
{<br />
strPartNumberInputReference = txtPartNumberInput.Text;<br />
<br />
<br />
string SQLString = "SELECT p.PartNumber, pt.description, dd.DrawingNumber, dd.DrawingRevision, dd.DwgPath FROM parts p INNER JOIN PartTypes pt on pt.ID =p.PartTypeID LEFT JOIN DraftingData dd on dd.PartID = p.ID WHERE p.PartNumber = @PartID;SELECT w.weight, wt.Description AS wtDescription, p.PartNumber from weights w INNER JOIN weighttypes wt on wt.ID = w.weighttypeid INNER JOIN Parts p on w.PartID = p.ID WHERE p.PartNumber = @PartID;SELECT c.cost, p.PartNumber, ct.Description AS ctDescription from Costs c INNER JOIN Parts p ON c.PartID = p.Id INNER JOIN CostTypes ct on ct.Id = c.CostTypeID WHERE p.PartNumber = @PartID; SELECT s.SubPartID, s.Quantity, s.Sequence, p.PartNumber FROM SubParts s INNER JOIN Parts p ON s.PartID = p.Id "; <br />
<br />
<br />
SqlCommand cmd = new SqlCommand();<br />
cmd.Connection = new SqlConnection(strConnectSQL);<br />
cmd.CommandText = SQLString;<br />
cmd.Parameters.Add ("@PartID", strPartNumberInputReference);<br />
SqlDataAdapter adapter = new SqlDataAdapter(cmd);<br />
adapter.Fill(ds);<br />
<br />
<br />
ds.Tables[1].TableName = "Weights";<br />
ds.Tables[2].TableName = "Costs";<br />
ds.Tables[3].TableName = "Subparts";<br />
<br />
dgParts.DataSource = ds;<br />
dgParts.DataBind();<br />
txtPartNumberInput.Text = "";<br />
}
So when the user enters the data the grid comes back perfect. Just how I want it. BUT when I hit the Edit button, I get back to the problem of bogus data.
public void dgParts_edit (object sender, DataGridCommandEventArgs e)<br />
{<br />
dgParts.EditItemIndex = e.Item.ItemIndex;<br />
BindData();<br />
}
So I'm still not sure what I am doing wrong.
|
|
|
|
|
I'm not exactly sure what you meant by bogus data.
Do you mean the child tables are showing the wrong data?
Try setting the CurrentRowIndex of the datagrid instead.
"Democracy is two wolves and a sheep voting on what to have for dinner" - Ross
Edbert
Sydney, Australia
|
|
|
|
|
I'm looking for the SQL equivalent to Scott Meyer's "Effective C++; 50 Specific ways to improve your pograms and designs".
Thanks,
Dave
Rocket science is more fun when you actually have rockets - US Navy ad
|
|
|
|
|
SQL For Smarties[^] is one of the best SQL books I've seen.
----------
Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them.
- Laurence J. Peters
|
|
|
|
|
hi
how to extract column names of a perticular table
can anyone tell me the query for that
Thanks
Thanks
|
|
|
|
|
|
Thanks for help
but its not working i dont know whats the proble
Actually i am using ms access database
where GeometryData.mdb is my database name and iges_data is my table name
Please help me
Thanks
|
|
|
|
|
hello,
try out ..
one of these..
1. sp_columns tablename
2. select name from syscolumns where id = object_id('tablename')
vivek
|
|
|
|
|
|
Hi, I'm beginner to .NET...
I'm trying to access an Oracle Database using a ASP.Net webservice with C#.... I'm using VS.NET 2005 and Oracele 10g...
Created an System DSN using the Oracle ODBC driver
I tried using an OdbcConnection
String constr = String.Format("DSN={0};UID={1};PWD={2};", "TEST", "user", "passwd");
con = new OdbcConnection(constr);
con.open();
This code works fine with a C# client program, but when I tried it with the webservice I get the following error...
Error[IM003] Specified driver could not be loaded due to sytem error 5(Oracle in OraClient10g_home1)
ny ideas? Am I missing something...?? Plz help if possible...
Mahesh
|
|
|
|
|
Are you importing the correct namespaces in your webservice
You may also have to install an oracle client driver I've had issues with this in the past.
Look where you want to go not where you don't want to crash.
Bikers Bible
|
|
|
|
|
Hi,
Yes, I'm using System.Data.Odbc and I hav the Oracle client for 10g rel 1 installed... The connection opens correctly when I use the code in a C# windows application... I only get the error when using it in the webservice....
|
|
|
|
|