|
I am using Data Application Block of June 2005 version of enterprise library. I am able to use the executeNonQuery method which is given in the quick starts.
string sqlCommand = "USP_U_ChangeUserPassword";
Database db = DatabaseFactory.CreateDatabase();
DBCommandWrapper commandWrapper = db.GetStoredProcCommandWrapper(sqlCommand);
commandWrapper.AddInParameter("@password", DbType.String, password);
db.ExecuteNonQuery(commandWrapper)
But this way we will not get the number of affected rows.
I tried to use the overloaded ExecuteNonQuery() which returns affected rows
eg,
string sqlCommand = "spChangeName";
Database db = DatabaseFactory.CreateDatabase();
SqlParameter[] arParams = new SqlParameter[2];
SqlParameter param1 = new SqlParameter("@FName", DbType.String);
param1.Value = "Johnson22";
arParams[0] = param1;
SqlParameter param2 = new SqlParameter("@LName", DbType.String);
param2.Value = "White";
arParams[1] = param2;
int affectedRows = db.ExecuteNonQuery("spChangeName", arParams);
But this is throwing the following error
Failed to convert parameter value from a SqlParameter to a string.
Please provide me a solution for this issue
|
|
|
|
|
|
I'm wondering if you can access RowsAffected of the command wrapper, and if that would properly give you back the rows affected.
<br />
...<br />
Database db = DatabaseFactory.CreateDatabase();<br />
DBCommandWrapper commandWrapper = db.GetStoredProcCommandWrapper(sqlCommand); <br />
commandWrapper.AddInParameter("@password", DbType.String, password); <br />
db.ExecuteNonQuery(commandWrapper);<br />
<br />
int rowsAffected = commandWrapper.RowsAffected;<br />
I haven't tried this myself, so I'm sorry if I'm looking in the wrong direction.
-- modified at 20:28 Wednesday 31st August, 2005
|
|
|
|
|
Thanks Susan, your suggestion is working fine
|
|
|
|
|
FYI
I think the reason your second example did not work was because you were trying to pass in a SqlParameter array into db.ExecuteNonQuery , whereas looking at the constructor for it, it looks like it's asking for an object array of the actual values, not the parameters:
public virtual int ExecuteNonQuery(string storedProcedureName, params object[] parameterValues)
So I would guess that your second code sample should be something like:
string storedProcName = "spChangeName";<br />
Database db = DatabaseFactory.CreateDatabase();<br />
<br />
int affectedRows = db.ExecuteNonQuery(storedProcName, "Johnson22", "White");<br />
|
|
|
|
|
Hello!
I am trying to use a DLL that contains functions of c++ in c # but I have not been able to make it, this DLL is of a software called LOOX Maker, which is a editor graphic that has many options reason why I want to reuse that code and not to have to program it again, also i have the source of this program, I have tried several things but I have not obtained it. somebody that has more experience in this type of things can help me? I can send the project to you where I am trying to use it and also the DLL and source code of LOOX Maker, I hope that somebody can help me.
|
|
|
|
|
|
Hi all. I've been using C#.net for about 6 months and love it. I have several projects that I would like to roll under one project. Now, while I understand how to import the projects in to my main project, I am having a hard time calling those project forms from my main form menu and I also get an error that my main form and the other project forms have multiple entry points.
Can someone please help me understand this quandry and help me find a solution? I'm sure you genius' out there know how to fix this and are grinning as you read this.
Sincerely,
J. Barber
C#.net newby!
|
|
|
|
|
You have a solution file (.sln) that contains multiple projects files (.csproj).
For one project to call some object in another project, you need to right-click on the project's references in Visual Studio and Add Reference to the other project. Then you'll be able to call any object in the project you just added a reference to.
As for multiple entry points, that's the compiler telling you that several of your projects contain a "static void Main" method, which is always the entry point for an executable. You can only have one static void main per project.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Cops & Robbers
Judah Himango
|
|
|
|
|
Hi Barbar,
if you create a common windows application, Microsoft Visual Studio create a project with one Form. And this form has a static Method Main . This Main is the entry point for your Application (the first called Method). All you have to do is to make sure that you have exactly one static Main method.
For instance, create a new class and add a static Main method and delete all others Main s.
It's unimportant where you define your Main method.
Lars Niedziolka
|
|
|
|
|
Hi!
thanks for help
I'm a beginner in C#.net and this is my question:
in my database application and in my form , I use 2 table from SQL .In table1(mainTable) my fields are id_car,car,id_city and in Table2 my fields are id_city,city.id_city in table1 has a relation to id_city in Table2 , but I want to fill the Datagrid by table1 .I have a textbox,combobox and a datagrid ,in my form and for displaying the records , I use a View in SQL .
THANKS if anyone to reply that How can I add,update,Delete
the table in my form .by the way ,I try to find a sample for my reply ,but I Can't .
thanks in advance!!!
Mostafa
|
|
|
|
|
You can write somthing like
SqlDataAdapter adabter=new SqlDataAdapter("Select id_car,car,id_city from table1","Your connection string");
DataTable dt=new DataTable("tableName");
adabter.Fill(dt);
textBox1.DataBindings.Add("Text",dt,"id_car");
other control like datagrid have Datasource property
which you can use it to display data in the datagrid
for more info look at
ADO.NET Overview[^]
Note:
if you use database other than sql server use its data provider classes
MCAD
|
|
|
|
|
I have the following code below to send an email. It works 100%. So I have no problem with that at all. However, if I comment out the message.Body section, and uncomment the other message.Body section, this code will no longer send out an email, and I have no idea why. Can anyone explain this?
string body = "18";
SmtpMail.SmtpServer = "192.168.0.2";
MailMessage message = new MailMessage();
message.To = "ray@email.co.za";
message.From = "test@email.co.za";
message.BodyFormat = MailFormat.Text;
message.Subject = subject;//"New Accident Management report on Risk Management Website";
message.Body = "http://localhost/riskmanagement/customer.aspx?refNumber=" + body;
//message.Body = "http://" + HttpContext.Current.Request.Url.Host + "/RiskManagement.Presentation.WebSite/AccidentManagement/AccidentMaintenance.aspx?refNumber=" + body;
SmtpMail.Send(message);
|
|
|
|
|
Stick a breakpoint in, and check that HttpContext.Current.Request.Url.Host returns something sensible - that might be what's confusing it
--
Help me! I'm turning into a grapefruit!
Buzzwords!
|
|
|
|
|
Hi for all
I've seen this in a source code, how can I interpret this?
unsigned char tab4[256]=
{
0x00,0x80,0x40,0xc0,0x20,0xa0,0x60,0xe0,0x10,0x90,0x50,0xd0,0x30,0xb0,0x70,0xf0,
0x08,0x88,0x48,0xc8,0x28,0xa8,0x68,0xe8,0x18,0x98,0x58,0xd8,0x38,0xb8,0x78,0xf8,
0x04,0x84,0x44,0xc4,0x24,0xa4,0x64,0xe4,0x14,0x94,0x54,0xd4,0x34,0xb4,0x74,0xf4,
0x0c,0x8c,0x4c,0xcc,0x2c,0xac,0x6c,0xec,0x1c,0x9c,0x5c,0xdc,0x3c,0xbc,0x7c,0xfc,
0x02,0x82,0x42,0xc2,0x22,0xa2,0x62,0xe2,0x12,0x92,0x52,0xd2,0x32,0xb2,0x72,0xf2,
0x0a,0x8a,0x4a,0xca,0x2a,0xaa,0x6a,0xea,0x1a,0x9a,0x5a,0xda,0x3a,0xba,0x7a,0xfa,
0x06,0x86,0x46,0xc6,0x26,0xa6,0x66,0xe6,0x16,0x96,0x56,0xd6,0x36,0xb6,0x76,0xf6,
0x0e,0x8e,0x4e,0xce,0x2e,0xae,0x6e,0xee,0x1e,0x9e,0x5e,0xde,0x3e,0xbe,0x7e,0xfe,
0x01,0x81,0x41,0xc1,0x21,0xa1,0x61,0xe1,0x11,0x91,0x51,0xd1,0x31,0xb1,0x71,0xf1,
0x09,0x89,0x49,0xc9,0x29,0xa9,0x69,0xe9,0x19,0x99,0x59,0xd9,0x39,0xb9,0x79,0xf9,
0x05,0x85,0x45,0xc5,0x25,0xa5,0x65,0xe5,0x15,0x95,0x55,0xd5,0x35,0xb5,0x75,0xf5,
0x0d,0x8d,0x4d,0xcd,0x2d,0xad,0x6d,0xed,0x1d,0x9d,0x5d,0xdd,0x3d,0xbd,0x7d,0xfd,
0x03,0x83,0x43,0xc3,0x23,0xa3,0x63,0xe3,0x13,0x93,0x53,0xd3,0x33,0xb3,0x73,0xf3,
0x0b,0x8b,0x4b,0xcb,0x2b,0xab,0x6b,0xeb,0x1b,0x9b,0x5b,0xdb,0x3b,0xbb,0x7b,0xfb,
0x07,0x87,0x47,0xc7,0x27,0xa7,0x67,0xe7,0x17,0x97,0x57,0xd7,0x37,0xb7,0x77,0xf7,
0x0f,0x8f,0x4f,0xcf,0x2f,0xaf,0x6f,0xef,0x1f,0x9f,0x5f,0xdf,0x3f,0xbf,0x7f,0xff
};
Thanks
|
|
|
|
|
hi there,
those are just hexa number
|
|
|
|
|
You can interpret it as an array of length 256 that contains unsigned characters, otherwise known as 8-bit Byte values. If the 0x is the confusing part, that's just the notation for hexadecimal format. If you don't know what Hex is, then my friend, you have a lot left to learn
|
|
|
|
|
ok man, thanks. The 0x was the confusing part, I think that was memory address.
|
|
|
|
|
Hi
I am developing a ASP.Net application. My application have 5 layers. (1) Web Layer (2) Business Logic Layer (3) Data Access Layer (4) Business Entity (5) System Framework.
I want to put Exception Management Application Block (EMAB) in SystemFramework layer, so that it can be accessible from all layer. In SystemFramework layer i put EMAB (2 dlls Microsoft.ApplicationBlocks.ExceptionManagement and Microsoft.ApplicationBlocks.ExceptionManagement.Interfaces.dll), ExceptionPublisher.cs and ExceptionXMLPublisher.cs. I can access ExceptionPublisher.cs and ExceptionXMLPublisher.cs from other layers but to publish error i have to access ExceptionManager.Publish which is not accessible.
Anyone know what to do.
Danech
|
|
|
|
|
Please tell me how can i build my own graphic chart control in ASP.NET and c#
|
|
|
|
|
hi there,
first, u need to get familiar with System.Drawing namespace
then, u can read and follow some useful articles related to it to build your own chart control in asp.net.
There are some couple of good article on CP that u can learn from them. U can search on this site, below are just some of them
+http://www.codeproject.com/aspnet/3dpiechart.asp#xx832178xx
+http://www.codeproject.com/aspnet/Creating_Charts.asp
Hope this helps
Happy programming
<< >>
|
|
|
|
|
i wrote the ms Word Addin. when i want to uninstall it. after the uninstall Process
Commplted.
the addin exists in ms word enviroment and dosen't work how can i remove it from
enviroment.
tank's in advance
rashidi
|
|
|
|
|
u can try this go to start menu click on control panel then go to add or remove programs if ur addin is there just remove it.
|
|
|
|
|
i rempved it from add/remove program and all this is ok.
when i return in ms enviroment .the addin exists but thier function dosen't work.
now i want to remove from word enviroment too.
what's the problem?
tank's in advance.
rashidi
|
|
|
|
|
Hi im using a data view to populate my datagrid but am unable to use DataGridTableStyle. When populating my datagrid directly with a DataTable I set the DataGridTableStyle.MappingName to my DataTable name and am able to change the look of the table and columns without any trouble. When using the dataview i get no errors just a blank datagrid. Is it not possible to use the two together?
Here is the code anyway, if someone could spot my mistakes it would be great!
**Working Code**
DataSet ds = new DataSet();
ds.ReadXml("xml.xml");
DataGrid dg = new DataGrid();
dg.DataSource = ds;
dg.DataMember = "Players";
DataGridTableStyle dgts = new DataGridTableStyle();
dgts.MappingName = "Players";
dgts.RowHeadersVisible = false;
dgts.PreferredRowHeight = 24;
dg.TableStyles.Add(dgts);
**Broken Code**
DataSet ds = new DataSet();
ds.ReadXml("xml.xml");
DataView dv = new DataView(ds.Tables["Player"]);
DataGrid dg = new DataGrid();
dg.DataSource = dv;
//dg.DataMember = "Players"; **this line causes error**
DataGridTableStyle dgts = new DataGridTableStyle();
dgts.MappingName = "Players";
dgts.RowHeadersVisible = false;
dgts.PreferredRowHeight = 24;
dg.TableStyles.Add(dgts);
the broken code causes no errors just displays an empty grid (if i comment out the DataGridTableStyle code the grid dispalys just fine)
Thanks in advance!!
|
|
|
|
|