|
i couldnt delete a particular row from datagridview using binding navigator delete button.it deletes another id.not d selected row.whatz d solution
|
|
|
|
|
Are you using a SqlDataAdapter to fill the BindingSource? How does the DeleteCommand[^] look? Can you post it here?
I are Troll
|
|
|
|
|
yup.um using a SqlDataAdapter.
string sql = "select id,name,contact,meal_num,cost,due from info";
SqlDataAdapter da = new SqlDataAdapter(sql, con.objConn);
DataTable data_table = new DataTable();
da.Fill(data_table);
dataGridView2.DataSource = data_table;
BindingSource bindingSource = new BindingSource(data_table,null);
dataGridView2.DataSource = bindingSource;
bindingNavigator1.BindingSource = bindingSource;
dataGridView2.Columns[0].Visible = false;
string s = "delete from info where id='" + dataGridView2.CurrentRow.Cells[0].Value + "'";
try
{
SqlCommand sqlCmd = new SqlCommand(s, con.objConn);
con.objConn.Close();
con.objConn.Open();
sqlCmd.ExecuteNonQuery();
con.objConn.Close();
// return true;
}
catch (Exception e5)
{
con.objConn.Close();
// return false;
}
i solved d problem using another button.problem occurs only when i want to delete using d delete button of d binding navigator.
|
|
|
|
|
i want to fix headr of my gridview fix,i have searched many solutions but the problem is ,i need to get work in ie,firefox and opera.solutions are on the internet but i could not find a solution that work in three browsers.
Thank you in advance
|
|
|
|
|
The app was compiled for the .net framework 3.5. I have other tester of the app that live within the US, but my only european test is having trouble opening the app. He says when he double clicks the app it doesn't do anything. Not even an error. It simply doesn't opne. He has the right framework installed, and running Vista. I have searched far and wide for an answer. Do, I need to set the application properties to compile for a specific machine?
|
|
|
|
|
Hi,
it sounds like your app is failing early on and not producing anything. Maybe there is an uncatched exception in the constructor of the main form.
here is some advice:
- always include code to log your internal events to a text file, which the customer can mail to you for inspection.
- log the start time, the OS version, and whatever may be relevant before your app starts;
- make sure you catch all exceptions; when you got one, log it (using ToString, not just Message) and deal with it or throw it again, but don't just ignore it.
- test your app on all relevant Windows versions at your place, don't ship it for a version you haven't tested yourself.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. [The QA section does it automatically now, I hope we soon get it on regular forums as well]
|
|
|
|
|
Since this is Vista, you may want to trying running the app with the "run as administrator" property set to true.
Me, I'm dishonest. And a dishonest man you can always trust to be dishonest. Honestly. It's the honest ones you want to watch out for...
|
|
|
|
|
|
how i can install window application with sql database
|
|
|
|
|
|
I don't know how to initialize parameters to call method of COM object via COMObjectVariable.GetType().InvokeMember(..,parameters,.).
COM object is inherited from IDispatch interface and definition of calling method in IDL is:
[id(0x0000201c), helpstring("Returns the Dimensions collection object for the referenced object."), helpcontext(0x00007553)]
void GetDimensions(
[out] long* NumDimensions,
[in, out] SAFEARRAY(IDispatch*)* Dimensions);
My code in C# is:
object COMObjVar=...; //assign instance of COM IDispatch object to variable COMObjVar
object[] Params=new object[2];
int NumDimensions=0;
Array Dimensions=Array.CreateInstance(typeof(object),0);
ParameterModifier[] Modifiers=new ParameterModifier(2);
Modifiers[0]=new ParameterModifier(1);
Modifiers[0][0]=true;
Modifiers[1]=new ParameterModifier(1);
Modifiers[1][0]=true;
COMObjVar.GetType().InvokeMember("GetDimensions",BindingFlags.InvokeMethod, null, COMObjVar, Params, Modifiers, null, null); //throw TargetInvocationException with Inner COM exception "Type mismatch. (Exception from HRESULT: 0x80020005 (DISP_E_TYPEMISMATCH))"
When i call method COMObject.GetType().InvokeMember(...) program throw TargetInvocationException with Inner COM exception "Type mismatch. (Exception from HRESULT: 0x80020005 (DISP_E_TYPEMISMATCH))".
How to initialize method parameters correct?
Thanks.
|
|
|
|
|
You have also to set some parameters.
In your case you wrote
object[] Params=new object[2];
but I can't find something like
Params[0] = NumDimensions; or
Params[1] = Dimensions; .
Actually you call this function without a valid parameter.
Greetings
Covean
|
|
|
|
|
Sorry, I just forgot to type in.
Corrected code is:
object COMObjVar=...; //assign instance of COM IDispatch object to variable COMObjVar
object[] Params=new object[2];
int NumDimensions=0;
Array Dimensions=Array.CreateInstance(typeof(object),0);
Params[0]=NumDimensions;
Params[1]=Dimensions;
ParameterModifier[] Modifiers=new ParameterModifier(2);
Modifiers[0]=new ParameterModifier(1);
Modifiers[0][0]=true;
Modifiers[1]=new ParameterModifier(1);
Modifiers[1][0]=true;
COMObjVar.GetType().InvokeMember("GetDimensions",BindingFlags.InvokeMethod, null, COMObjVar, Params, Modifiers, null, null); //throw TargetInvocationException with Inner COM exception "Type mismatch. (Exception from HRESULT: 0x80020005 (DISP_E_TYPEMISMATCH))"
|
|
|
|
|
I never worked with ParameterModifier but if I take a look at the example in MSDN and on your code there is a difference that can explain the problem:
So try this:
ParameterModifier p = new ParameterModifier(2);
p[0] = true;
p[1] = true;
ParameterModifier[] mods = { p };
COMObjVar.GetType().InvokeMember(..., mods, ...);
Hope this helps.
Greetings
Covean
|
|
|
|
|
I tried it and it works.
Thanks.
|
|
|
|
|
sir i want to save the data from windows application to ms access my code is:
OleDbConnection conn = new OleDbConnection();
conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\\siddharth.mdb";
OleDbDataAdapter da = new OleDbDataAdapter("select * from table1", conn);
OleDbCommandBuilder cb = new OleDbCommandBuilder(da);
DataSet ds = new DataSet();
da.Fill(ds);
DataRow dr = ds.Tables[0].NewRow();
dr["id"] = textBox1.Text;
dr["name1"] = textBox2.Text;
dr["phone_no"] = textBox3.Text;
ds.Tables[0].Rows.Add(dr);
da.Update(ds);
MessageBox.Show("Data has been inserted successfully", "MESSAGE", MessageBoxButtons.OK, MessageBoxIcon.Information);
but i m unly see the data at the run time not permanently so sir plz help me.............
--
siddharth
|
|
|
|
|
OleDbCommandBuilder would generate the Insert, Delete and Update commands when you have set the SelectCommand for the OleDbDataAdapter. Here you have not done that.
Set the SelectCommand for the adapter to your select statement and it should work.
"No matter how many fish in the sea; it will be so empty without me." - From song "Without me" by Eminem
|
|
|
|
|
Hi All,
I am trying to load a XAML string and convert it into a FlowDocument object as follows:
return XamlXmlReader.Load(new XmlTextReader(new StringReader(xaml))) as FlowDocument;
It seems that the Load function has not been implemented (yet?) in the Beta 2 of Framework 4. According to all documentation that I can find it should be there, or at least XamlReader.Load
How can I convert a XAML string to a FlowDocument otherwise ?
Thanks
OD
|
|
|
|
|
I eventually managed to solve my problem; it turned out to be a namespace problem.
The XamlXmlReader and XamlReader classes I tried using existed in the System.Xaml namespace.
I should have used the classes in the System.Windows.Markup namespace.
The solution thus was:
return System.Windows.Markup.XamlReader.Load(new XmlTextReader(new StringReader(xaml))) as FlowDocument;
Works like a charm !
OD
|
|
|
|
|
Hi!
I have installed an 'old and rusted' version of Visual Studio 2003, with comes with base .NET Framework 1. I have some questions...
Can I install and use .Net Framework 2 and 3 with Visual Studio 2003? What files do I have to dounload and install? Just the standard 'redistributable packs'?
Can all of tree been simultaneously installed?
Do I have to use some directive or somehow config Visual Studio to use one or other version? Or all thre convive / overlap simultaneously?
What will I have access to? I supponse classes, controls, funcionalities (like Generics)? Will some new controls appear automatically on my toolbar, or I will have to manually regiser?
Sorry for so many inquiries... and thanks in advance for your replies!
|
|
|
|
|
VS 2003 supported only the .NET Framework 1.1. Although you can install other versions of the framework side by side, you can't use them in VS2003.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Hello,
I would like to ask how can I do a search with filter
in vb 2008 or a sample code will be appreciated. The database connection that I am using is ms access and the connection
I used to connect my program
is OLEDB connection. Any reply will be kindly appreciated.
Thanks,
dfan23
|
|
|
|
|
Since you are searching values in the database, queries would be doing the actual work. Now, the basic query would be:
Select columnNames from tableName
Now, when someone applies a filter, the query you would need to create would be like:
Select columnNames from tableName where someColumn in (selcted values)
Now, it depends on the way you are creating the query. You would need to update the code where you create the query or the stored procedure which does the search to include the selected filter in the where clause.
"No matter how many fish in the sea; it will be so empty without me." - From song "Without me" by Eminem
|
|
|
|
|
Hello,
Thanks for immediate response, now I have the idea.
thanks,
dfan23
|
|
|
|
|
Hi. I'm quite new to using DataSets/DataAdapters.
At first, I tried to populate my DataSet (which consists of several tables) with one select query, like so:
var cmd =
new SqlCommand("SELECT * FROM TableOne;SELECT * FROM TableTwo", con);
myDataAdapter= new SqlDataAdapter(cmd);
myDataAdapter.Fill(ds);
I then proceed to set the primary key for TableTwo in the dataset and instantiate a SqlCommandBuilder with the Adapter as parameter.
When I eventually call myDataAdapter.Update(ds.Tables["TableTwo"]); the adapter gets confused and complains that it can't find a column from TableOne in TableTwo. I googled around and read that you can fix this problem by using seperate DataAdapters for each table in the DataSet. I tried this, creating a new SqlCommand for each adapter with only one select query in each, but calling the second myDataAdapter.Fill overwrites the contents of the DataSet completely!
Of course I could use seperate DataSets for each table but that seems like the incorrect solution. I've googled for tutorials and examples but all of them are too simple to help me (never more than 1 table in the DataSet, and some other issues as well).
Basically, I'd appreciate some advice on how to approach this problem - is it doable with one DataAdapter? if so, how do I get the DataAdapter to understand my DataSet (which seems to be the problem here..)? Otherwise, how do I use more than one DataAdapter to populate a single DataSet?
Thanks in advance for any help...
|
|
|
|
|
I may have found a solution - naming the tables directly after calling Fill SEEMS to help. I always get these revelations just after posting....
|
|
|
|