Click here to Skip to main content
16,018,529 members

Comments by DevParashar (Top 14 by date)

DevParashar 15-May-14 2:40am View    
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace CMb
{
public partial class Form1 : Form
{
SqlConnection connect = new SqlConnection("Data Source=Admin;Initial Catalog=Practice_DatabaseSQL;User Id=sa;password=p@ssw0rd");

public Form1()
{
InitializeComponent();
bmbBind();
}

void bmbBind()
{
connect.Open();
SqlCommand cmd = new SqlCommand("SELECT Distinct SoftwareName from dbo.Keys", connect);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
da.Fill(dt);

if (dt.Rows.Count > 0)
{
cmbNameS.DataSource = dt;
cmbNameS.DisplayMember = "SoftwareName";
cmbNameS.ValueMember = "SoftwareName";
}
}

private void cmbVersion_SelectedIndexChanged(object sender, EventArgs e)
{
string query = "Select SKeys from dbo.Keys where SoftwareName='" + cmbVersion.SelectedValue + "'";
SqlCommand cmd = new SqlCommand(query, connect);
SqlDataReader data =cmd.ExecuteReader();

if ( data.Read())
{
txtKeys.Text = data.GetSqlValue(0).ToString();
}

}

private void cmbNameS_SelectedIndexChanged(object sender, EventArgs e)
{

string query = "Select VersionNo from dbo.Keys where SoftwareName='" + cmbNameS.SelectedValue + "'";
SqlCommand cmd = new SqlCommand(query, connect);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
da.Fill(dt);

if (dt.Rows.Count > 0)
{
cmbVersion.DataSource = dt;
cmbVersion.DisplayMember = "VersionNo";
cmbVersion.ValueMember = "VersionNo";
}
}

}
}



I have the following code changes but not able to get the desired output in the textbox
DevParashar 14-May-14 14:55pm View    
OK this is the code that i added but is not working..

private void cmbNameS_SelectedIndexChanged(object sender, EventArgs e)
{

string query = "Select VersionNo from dbo.Keys where SoftwareName='" + cmbNameS.SelectedValue + "'";
SqlCommand com = new SqlCommand(query, connect);
SqlDataReader dr = com.ExecuteReader();

if (dr.Read())
{
txtKeys.Text = dr["Key"].ToString();
}
}
DevParashar 14-May-14 14:42pm View    
Deleted
Could you please suggest this part of the code as I am not much familiar to C# coding..

Will be very helpful..
DevParashar 13-May-14 2:09am View    
The error is as follows:
(
System.Data.OleDb.OleDbException: Could not finf installable ISAM. at System.Data.OleDb.OleDbConnectionInternal..ctor(OnleDbConnectionString constr, OleDbConnection connection) at System.Data.OleDb
DevParashar 10-May-14 23:55pm View    
Deleted
I am making a simple application using ms access as my database. The application has two types of users ADMIN and employees. Based on my Login there are certain feature that need to be allowed/restricted - such as if i login as employee I will get only to add data to my work and view my results and search for my work related results. But as an admin i should have full access to my application and database. I have to create this using C# and Windows Forms Application..

Thanks and regards